#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long inf = 1LL << 30;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int N = 200200;
map<pair<long long, long long>, long long> mp;
map<long long, long long> mp2;
int main() {
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  long long cnt0 = 0, cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < n; i++) {
    long long x, vx, vy;
    scanf("%lld%lld%lld", &x, &vx, &vy);
    if (vx == 0 && vy == 0)
      cnt0++;
    else if (vx * a == vy && vy > 0)
      cnt1++;
    else if (vx * a == vy && vy < 0)
      cnt2++;
    else {
      vx *= a;
      mp[{vy - vx, vy}]++;
      mp2[vy - vx]++;
    }
  }
  long long ans = cnt1 * cnt2 * 2;
  ans += cnt0 * (cnt1 + cnt2);
  for (auto p : mp) {
    long long y = p.second;
    long long x = mp2[p.first.first];
    ans += y * (x - y);
  }
  printf("%lld", ans);
}
