#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int M = 1e4 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
long long n, a, b;
map<long long, int> mp;
map<pair<long long, long long>, int> mp2;
int main() {
  scanf("%lld%lld%lld", &n, &a, &b);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long vx, vy, x;
    scanf("%lld%lld%lld", &x, &vx, &vy);
    long long y = a * x + b;
    ans += mp[vy - a * vx];
    ans -= mp2[make_pair(vx, vy)];
    mp[vy - a * vx]++;
    mp2[make_pair(vx, vy)]++;
  }
  printf("%lld\n", ans * 2);
  return 0;
}
