#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
struct node {
  long long vx, vy;
  long long c;
};
int cmp(node a, node b) {
  if (a.vx == b.vx) return (a.vy > b.vy);
  return (a.vx > b.vx);
}
long long n, A, B;
node p[maxn];
map<long long, long long> mp;
int main() {
  long long x, xx, yy, temp;
  scanf("%lld%lld%lld", &n, &A, &B);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld", &x, &p[i].vx, &p[i].vy);
    temp = p[i].vy - A * p[i].vx;
    mp[temp]++;
  }
  long long ans = 0;
  map<long long, long long>::iterator it;
  for (it = mp.begin(); it != mp.end(); it++) {
    temp = it->second;
    ans = ans + (temp - 1) * temp;
  }
  sort(p, p + n, cmp);
  long long pos = 0, d;
  while (pos < n) {
    temp = pos;
    while (pos + 1 < n && p[pos].vx == p[pos + 1].vx &&
           p[pos].vy == p[pos + 1].vy)
      pos++;
    pos++;
    d = pos - temp;
    ans = ans - d * (d - 1);
  }
  printf("%lld", ans);
  return 0;
}
