#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
map<long long, long long> m1;
map<pair<long long, long long>, long long> m2;
int main() {
  long long a, b, n, ans = 0, xx, vx, vy;
  ;
  scanf("%lld%lld%lld", &n, &a, &b);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld%lld", &xx, &vx, &vy);
    long long ret = vy - vx * a;
    ans += m1[ret] - m2[make_pair(vx, vy)];
    m1[ret]++;
    m2[make_pair(vx, vy)]++;
  }
  printf("%lld\n", ans * 2);
  return 0;
}
