#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long powmod(long long a, long long b, long long d) {
  return (b == 1) ? a % d
                  : ((b & 1) ? a : 1) % d * powmod(a * a % d, b >> 1, d) % d;
}
pair<long long, long long> extgcd(long long a, long long b,
                                  long long *x = new long long(1),
                                  long long *y = new long long(0)) {
  if (b) {
    extgcd(b, a % b, x, y);
    long long tmp = *x;
    *x = *y;
    *y = tmp - a / b * (*y);
  }
  return {*x, *y};
}
long long modinv(long long a, long long n) {
  return (extgcd(a, n).first + n) % n;
}
long long ilg2(long long n) { return (n == 1) ? 0 : ilg2(n >> 1) + 1; }
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  long long x, vx, vy, eig, res = 0;
  map<long long, long long> eigen;
  map<pair<long long, long long>, long long> directions;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &x);
    ;
    scanf("%lld", &vx);
    ;
    scanf("%lld", &vy);
    ;
    eig = a * vx - vy;
    pair<long long, long long> direction;
    if (vx == 0 && vy == 0) {
      direction = {0, 0};
    } else {
      long long divisor = gcd(abs(vx), abs(vy));
      direction = {vx / divisor, vy / divisor};
    }
    if (eigen.count(eig) == 0)
      eigen[eig] = 1, directions[direction] = 1;
    else {
      if (directions.count(direction) == 0) {
        res += eigen[eig] * 2;
        directions[direction] = 1;
      } else {
        res += (eigen[eig] - directions[direction]) * 2;
        directions[direction]++;
      }
      eigen[eig]++;
    }
  }
  printf("%lld\n", res);
  return 0;
}
