#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, a, b;
  while (cin >> n >> a >> b) {
    vector<pair<long long, long long> > p;
    map<long long, long long> mp1;
    map<pair<long long, long long>, long long> mp2;
    for (long long i = 0; i < n; i++) {
      long long o, x, y;
      cin >> o >> x >> y;
      p.push_back({x, y});
      if (x == 0 && y == 0) continue;
      mp1[a * x - y]++;
      mp2[p[i]]++;
    }
    long long res = 0;
    for (long long i = 0; i < n; i++)
      res += mp1[p[i].first * a - p[i].second] - 1, res -= mp2[p[i]] - 1;
    cout << res << endl;
  }
}
