#include <bits/stdc++.h>
using namespace std;
const int maxN = 200005;
int main() {
  int n, a, b;
  map<pair<long long int, long long int>, int> velocityCounter;
  map<long long int, int> featureCounter;
  cin >> n >> a >> b;
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    long long int x, vx, vy;
    cin >> x >> vx >> vy;
    pair<long long int, long long int> velocity = make_pair(vx, vy);
    if (velocityCounter.find(velocity) != velocityCounter.end()) {
      sum -= velocityCounter[velocity];
      velocityCounter[velocity]++;
    } else {
      velocityCounter[velocity] = 1;
    }
    long long int feature = a * vx - vy;
    if (featureCounter.find(feature) != featureCounter.end()) {
      sum += featureCounter[feature];
      featureCounter[feature]++;
    } else {
      featureCounter[feature] = 1;
    }
  }
  cout << sum * 2;
}
