#include <bits/stdc++.h>
using namespace std;
int64_t gcd(int64_t a, int64_t b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int64_t N, A, B;
  cin >> N >> A >> B;
  map<int64_t, int64_t> mp;
  map<vector<int64_t>, int64_t> mp3;
  for (int i = 0; i < N; i++) {
    int64_t x, vx, vy;
    cin >> x >> vx >> vy;
    int64_t v = A * vx - vy;
    mp[v]++;
    int64_t g = gcd(abs(vx), abs(vy));
    if (g == 0) {
      mp3[{v, 0, 0}]++;
    } else {
      vx /= g;
      vy /= g;
      mp3[{v, vx, vy}]++;
    }
  }
  int64_t ans = 0;
  for (auto& p : mp) ans += p.second * (p.second - 1);
  for (auto& p : mp3) ans -= p.second * (p.second - 1);
  cout << ans << endl;
  return 0;
}
