#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const double eps = 1e-9;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 20;
const int maxm = 1e5 + 20;
int in(int &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return -1;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
map<long long, int> ma;
long long a[maxn];
int main() {
  int n;
  long long k, b;
  scanf("%d", &n);
  scanf("%lld%lld", &k, &b);
  long long sub = 0;
  for (int i = 1; i <= n; ++i) {
    long long v, x, y;
    scanf("%lld%lld%lld", &v, &x, &y);
    long long id = 2000000003LL * x + y;
    sub += ma[id] * 2;
    ++ma[id];
    a[i] = x * k - y;
  }
  long long ans = 0;
  ans -= sub;
  sort(a + 1, a + 1 + n);
  long long cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[i] == a[i - 1])
      ++cnt;
    else {
      ans += cnt * (cnt - 1);
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1);
  printf("%lld\n", ans);
  return 0;
}
