#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return f * x;
}
inline void write(long long a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10), putchar(a % 10 + '0');
}
const int MAX_N = 2e5 + 10;
long long n, a, b;
map<pair<long long, long long>, long long> m;
map<long long, long long> rec;
pair<long long, long long> p[MAX_N];
long long ans = 0;
int main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  long long x, v1, v2;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld", &x, &v1, &v2);
    b = v2 - a * v1;
    p[i] = make_pair(v1, v2);
    ans += (long long)rec[b];
    rec[b]++;
    ans -= (long long)m[p[i]];
    m[p[i]]++;
  }
  printf("%lld\n", ans << 1);
  return 0;
}
