#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
map<pair<long long, long long>, int> same;
int main() {
  long long n, a, b, ans = 0;
  scanf("%lld %lld %lld", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    long long x, vx, vy;
    scanf("%lld %lld %lld", &x, &vx, &vy);
    long long res = vy - a * vx;
    pair<long long, long long> node = (pair<long long, long long>){vx, vy};
    ans += mp[res] - same[node];
    mp[res]++;
    same[node]++;
  }
  printf("%lld\n", ans << 1);
  return 0;
}
