#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
map<pair<int, int>, int> vmp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, a, b, x, vx, vy;
  cin >> n >> a >> b;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> vx >> vy;
    long long t = (long long)a * vx - vy;
    ans += mp[t] - vmp[pair<int, int>(vx, vy)];
    mp[t]++;
    vmp[pair<int, int>(vx, vy)]++;
  }
  cout << (ans << 1) << endl;
  return 0;
}
