#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
int n;
long long int a, b;
long long int c[N], d[N];
map<long long int, long long int> freq;
map<pair<long long int, long long int>, long long int> freqp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    long long int x, ai, bi;
    cin >> x >> ai >> bi;
    freq[a * ai - bi]++;
    freqp[pair<long long int, long long int>(ai, bi)]++;
    c[i] = ai;
    d[i] = bi;
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += freq[a * c[i] - d[i]] -
           freqp[pair<long long int, long long int>(c[i], d[i])];
  }
  cout << ans << '\n';
  return 0;
}
