#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
long long ans;
map<long long, int> M;
map<pair<long long, long long>, int> M2;
int main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  for (long long i = 1; i <= n; i++) {
    long long x, vx, vy;
    scanf("%lld%lld%lld", &x, &vx, &vy);
    long long temp = vy - a * vx;
    ans += (M[temp] - M2[make_pair(vx, vy)]) * 2;
    M[temp]++;
    M2[make_pair(vx, vy)]++;
  }
  cout << ans << endl;
  return 0;
}
