#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  map<long long, long long> str;
  map<pair<long long, long long>, long long> str1;
  str1.clear();
  str.clear();
  for (int i = 0; i < n; i++) {
    long long pos, vx, vy;
    scanf("%lld%lld%lld", &pos, &vx, &vy);
    str[vy - a * vx]++;
    pair<long long, long long> p = pair<long long, long long>(vx, vy);
    str1[p]++;
  }
  long long sum = 0;
  map<pair<long long, long long>, long long>::iterator iter;
  for (iter = str1.begin(); iter != str1.end(); iter++) {
    long long k = (*iter).second;
    pair<long long, long long> p = (*iter).first;
    long long pos = p.second - a * p.first;
    if (k >= 2) {
      sum += (long long)k * (str[pos] - k);
    } else {
      sum += str[pos] - 1;
    }
  }
  cout << sum << endl;
  return 0;
}
