#include <bits/stdc++.h>
const int maxn = 0x3f3f3f3f;
const double EI =
    2.71828182845904523536028747135266249775724709369995957496696762772407663035354594571382178525166427;
const double PI = 3.141592653589793238462643383279;
const int p = 1e9 + 7;
using namespace std;
map<long long, long long> mp;
map<pair<long long, long long>, long long> mmp;
int main(void) {
  int n, i;
  long long a, b, x, vx, vy, ans;
  while (~scanf("%d %lld %lld", &n, &a, &b)) {
    mp.clear();
    mmp.clear();
    ans = 0;
    for (i = 0; i < n; i++) {
      scanf("%lld %lld %lld", &x, &vx, &vy);
      ans += mp[a * vx - vy]++;
      ans -= mmp[{vx, vy}]++;
    }
    printf("%lld\n", ans * 2);
  }
  return 0;
}
