#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  long long c[n][3];
  map<long long, long long> mp;
  map<pair<long long, long long>, long long> cord;
  for (unsigned long long i = 0; i < n; i++) {
    for (unsigned long long j = 0; j < 3; j++) cin >> c[i][j];
    c[i][1] *= a;
    cord[{c[i][1], c[i][2]}]++;
    mp[c[i][1] - c[i][2]]++;
  }
  long long ans = 0;
  for (auto i : mp) {
    long long ss = i.second;
    ans += ss * (ss - 1) / 2;
  }
  for (auto i : cord) {
    long long ss = i.second;
    ans -= ss * (ss - 1) / 2;
  }
  cout << 2 * ans << endl;
  return 0;
}
