#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int MAXN = 2e5 + 5;
const long long MOD = 1e9 + 7;
struct ghost {
  long long x, vx, vy;
} g[MAXN];
map<long long, long long> mp;
map<pair<long long, long long>, long long> mp2;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++)
    scanf("%lld%lld%lld", &g[i].x, &g[i].vx, &g[i].vy);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long vx = g[i].vx;
    long long vy = g[i].vy;
    if (vx == 0 && vy == 0) continue;
    ans += mp[a * vx - vy] - mp2[make_pair(vx, vy)];
    mp[a * vx - vy]++;
    mp2[make_pair(vx, vy)]++;
  }
  cout << ans * 2 << endl;
  return 0;
}
