#include <bits/stdc++.h>
using namespace std;
int n;
long long a, b, x, vx, vy;
map<long long, long long> mo;
map<long long, long long>::iterator it;
map<pair<long long, long long>, long long> ex;
map<pair<long long, long long>, long long>::iterator ti;
int main() {
  scanf("%d%I64d%I64d", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d%I64d", &x, &vx, &vy);
    mo[vy - a * vx]++;
    ex[make_pair(vx, vy)]++;
  }
  long long ans = 0;
  for (it = mo.begin(); it != mo.end(); it++) {
    long long tmp = it->second;
    ans += tmp * (tmp - 1);
  }
  for (ti = ex.begin(); ti != ex.end(); ti++) {
    long long tmp = ti->second;
    ans -= tmp * (tmp - 1);
  }
  printf("%I64d\n", ans);
  return 0;
}
