#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  vector<pair<long long, long long> > vec(n);
  for (int i = 0; i < n; i++) {
    long long a1, b1, c1;
    cin >> a1 >> b1 >> c1;
    a1 = (a * b1) - c1;
    vec[i] = {a1, b1};
  }
  sort(vec.begin(), vec.end());
  long long ans = 0;
  map<long long, long long> ma1;
  for (int i = 0; i < n; i++) {
    ma1[vec[i].first]++;
  }
  int in = 0;
  map<long long, long long>::iterator it;
  for (it = ma1.begin(); it != ma1.end(); it++) {
    map<long long, long long> ma2;
    for (int i = in; i < in + it->second; i++) {
      ma2[vec[i].second]++;
    }
    in += it->second;
    map<long long, long long>::iterator it1;
    for (it1 = ma2.begin(); it1 != ma2.end(); it1++) {
      ans += ((it->second - it1->second) * it1->second);
    }
  }
  cout << ans << endl;
  return 0;
}
