#include <bits/stdc++.h>
using namespace std;
template <class T>
void gi(T &x) {
  int f;
  char c;
  for (f = 1, c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
  x *= f;
}
const int N = 2e5 + 10;
int n, a, b;
map<long long, int> S;
map<pair<int, int>, int> T;
int main() {
  long long ans = 0;
  int x, vx, vy;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    gi(x);
    gi(vx);
    gi(vy);
    long long t = vy - 1ll * a * vx;
    ans += (S[t] - T[make_pair(vx, vy)]) << 1;
    S[t]++;
    T[make_pair(vx, vy)]++;
  }
  cout << ans << endl;
  return 0;
}
