#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
map<long long, long long> mp;
map<pair<long long, long long>, long long> dak;
long long n, a, b;
long long res;
signed main() {
  cin >> n >> a >> b;
  for (long long i = 1; i <= n; i++) {
    long long x, u, v;
    cin >> x >> u >> v;
    dak[{u, v}]++;
  }
  map<pair<long long, long long>, long long>::iterator it;
  for (it = dak.begin(); it != dak.end(); it++) {
    long long u = it->first.first;
    long long v = it->first.second;
    long long val = it->second;
    long long temp = a * u - v;
    if (mp[temp]) res += mp[temp] * val;
    mp[temp] += val;
  }
  cout << res * 2;
}
