#include <bits/stdc++.h>
using namespace std;
int main() {
  using ll = long long;
  map<ll, int> nr;
  map<tuple<ll, ll>, int> nr_;
  ll p = 0, m = 0, z = 0;
  int n, a, b;
  cin >> n >> a >> b;
  vector<tuple<int, int, int>> v(n);
  for (auto& x : v) cin >> get<0>(x) >> get<1>(x) >> get<2>(x);
  sort(begin(v), end(v));
  ll rez = 0;
  for (auto xxx : v) {
    int x, dx, dy;
    tie(x, dx, dy) = xxx;
    if (dx == 0 && dy == 0) {
      ++z;
      continue;
    }
    rez += nr[(ll)a * dx - dy];
    rez -= nr_[make_pair(dx, dy)];
    nr[(ll)a * dx - dy] += 1;
    nr_[make_pair(dx, dy)] += 1;
  }
  rez += (ll)p * m + (ll)p * z + (ll)m * z;
  cout << 2ll * rez << endl;
  return 0;
}
