#include <bits/stdc++.h>
using namespace std;
int n, a, b, x, y, z;
inline void work() {
  cin >> n >> a >> b;
  vector<pair<long long, int> > v;
  for (int i = 1; i <= n; ++i) {
    cin >> x >> y >> z;
    v.push_back(make_pair((long long)a * y - z, z));
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 0; i < v.size(); ++i) {
    int j = i;
    while (j + 1 < v.size() && v[i].first == v[j + 1].first) {
      ++j;
    }
    int len = j - i + 1;
    int k = i;
    while (k <= j) {
      int k1 = k;
      while (k1 + 1 <= j && v[k].second == v[k1 + 1].second) {
        ++k1;
      }
      ans += (long long)(k1 - k + 1) * (len - (k1 - k + 1));
      k = k1 + 1;
    }
    i = j;
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  work();
  return 0;
}
