#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
map<pair<long long, long long>, long long> s;
map<long long, long long> m;
map<long long, long long>::iterator it;
map<pair<long long, long long>, long long>::iterator itt;
int main() {
  long long n, a, b;
  long long x, vx, vy;
  scanf("%lld%lld%lld", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld", &x, &vx, &vy);
    m[a * vx - vy]++;
    s[make_pair(vx, vy)]++;
  }
  long long sum = 0;
  for (it = m.begin(); it != m.end(); it++) {
    long long t = it->second;
    sum += (t) * (t - 1) / 2;
  }
  for (itt = s.begin(); itt != s.end(); itt++) {
    long long t = itt->second;
    sum -= t * (t - 1) / 2;
  }
  printf("%lld", sum * 2);
  return 0;
}
