#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
map<pair<long long, long long>, int> mp1;
int main() {
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long x1, vx, vy;
    scanf("%lld%lld%lld", &x1, &vx, &vy);
    mp[vy - a * vx]++;
    mp1[make_pair(vx, vy)]++;
  }
  map<long long, int>::iterator it1;
  map<pair<long long, long long>, int>::iterator it2;
  for (it1 = mp.begin(); it1 != mp.end(); it1++) {
    long long cnt = it1->second;
    if (cnt > 1) ans += cnt * (cnt - 1) / 2;
  }
  for (it2 = mp1.begin(); it2 != mp1.end(); it2++) {
    long long cnt = it2->second;
    if (cnt > 1) ans -= cnt * (cnt - 1) / 2;
  }
  printf("%lld\n", 2 * ans);
  return 0;
}
