#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int N = 1e5 + 10;
long long n, a, b;
map<long long, long long> mp;
map<pair<long long, long long>, long long> mmp;
int main() {
  scanf("%I64d%I64d%I64d", &n, &a, &b);
  long long x, vx, vy;
  while (n--) {
    scanf("%I64d%I64d%I64d", &x, &vx, &vy);
    mp[a * vx - vy]++;
    mmp[pair<long long, long long>(vx, vy)]++;
  }
  long long ans = 0;
  map<long long, long long>::iterator it;
  map<pair<long long, long long>, long long>::iterator its;
  for (it = mp.begin(); it != mp.end(); it++) {
    ans += (it->second) * (it->second - 1);
  }
  for (its = mmp.begin(); its != mmp.end(); its++) {
    ans -= (its->second) * (its->second - 1);
  }
  printf("%I64d", ans);
  return 0;
}
