#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, a, b;
long long dist(int x, int y) { return 1LL * a * x - y + b; }
map<pair<int, int>, int> dir;
map<long long, int> cnt;
int vx[N], vy[N], x[N];
void solve() {
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cnt[dist(vx[i], vy[i])]++;
    dir[pair<int, int>(vx[i], vy[i])]++;
  }
  for (auto it = cnt.begin(); it != cnt.end(); it++) {
    ans += 1LL * it->second * (it->second - 1);
  }
  for (auto it = dir.begin(); it != dir.end(); it++) {
    ans -= 1LL * it->second * (it->second - 1);
  }
  printf("%lld\n", ans);
}
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", x + i, vx + i, vy + i);
  }
  solve();
  return 0;
}
