#include <bits/stdc++.h>
using namespace std;
pair<int, int> v[200004];
int n, a, b, i, x, st, dr, m, u;
long long s, c[200004];
int main() {
  scanf("%d %d %d", &n, &a, &b);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &x, &v[i].first, &v[i].second);
    c[i] = (0LL) + (1LL) * a * v[i].first - v[i].second;
  }
  sort(c + 1, c + n + 1);
  s = 0LL;
  for (i = 1; i <= n; i++) {
    st = i + 1;
    dr = n;
    while (st <= dr) {
      m = (st + dr) / 2;
      if (c[i] != c[m])
        dr = m - 1;
      else
        st = m + 1;
    }
    dr -= i;
    dr *= 2;
    s = (0LL) + s + dr;
  }
  sort(v + 1, v + n + 1);
  u = 1;
  for (i = 2; i <= n; i++) {
    if ((v[i].first == v[i - 1].first) && (v[i].second == v[i - 1].second)) {
      x = i - u;
      x *= 2;
      s = (0LL) + s - x;
    } else
      u = i;
  }
  printf("%I64d\n", s);
  return 0;
}
