#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b;
const int N = 200001;
long long x[N], y[N];
map<pair<long long, long long>, int> mp;
map<long long, int> cnt;
int main() {
  scanf("%d%lld%lld", &n, &a, &b);
  for (int i = 0; i < (int)n; i++) {
    int dum;
    scanf("%d", &dum);
    scanf("%lld%lld", &x[i], &y[i]);
    mp[{x[i], y[i]}]++;
  }
  long long r = 0;
  for (auto i : mp) {
    long long he = i.first.second - a * i.first.first;
    r += 1ll * cnt[he] * i.second;
    cnt[he] += i.second;
  }
  printf("%lld\n", r * 2);
  return 0;
}
