#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long double eps = 1e-8;
template <typename T>
void cmin(T &x, T y) {
  x = y < x ? y : x;
}
template <typename T>
void cmax(T &x, T y) {
  x = y > x ? y : x;
}
long long read() {
  char ch = getchar();
  long long x = 0;
  int op = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') op = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
  return x * op;
}
void write(long long a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10);
  putchar(a % 10 + '0');
}
long long ksm(long long x, long long p) {
  long long ret = 1;
  for (; p; p >>= 1, x = x * x)
    if (p & 1) ret = ret * x;
  return ret;
}
int n, A, B;
long long ans;
struct node {
  int x, vx, vy;
} a[200005];
map<long long, int> Mp;
map<pair<int, int>, int> Mp2;
int main() {
  n = read(), A = read(), B = read();
  for (int i = (1); i <= (n); i++) {
    a[i].x = read(), a[i].vx = read(), a[i].vy = read();
    long long tmp = (long long)a[i].vx * A - a[i].vy;
    ans += Mp[tmp];
    Mp[tmp]++;
    ans -= Mp2[pair<int, int>((int)a[i].vx, (int)a[i].vy)];
    Mp2[pair<int, int>((int)a[i].vx, (int)a[i].vy)]++;
  }
  ans *= 2ll;
  cout << ans << endl;
  return 0;
}
