#include <bits/stdc++.h>
using namespace std;
map<long long, int> f;
map<pair<long long, long long>, int> fxy;
int main() {
  int n, i;
  long long a, t, x, y, ans = 0;
  scanf("%d%I64d%I64d", &n, &a, &t);
  for (i = 0; i < n; i++) {
    scanf("%I64d%I64d%I64d", &t, &x, &y);
    t = a * x - y;
    ans += f[t] - fxy[make_pair(x, y)];
    f[t]++;
    fxy[make_pair(x, y)]++;
  }
  printf("%I64d\n", ans * 2);
  return 0;
}
