#include <bits/stdc++.h>
using namespace std;
map<pair<long long int, long long int>, int> mm;
pair<long long int, long long int> v[200005];
vector<long long int> st[200005];
long long int sum[200005];
int main() {
  mm[make_pair(1, 1)] = 1;
  pair<long long int, long long int> p;
  long long int n, a, b, x, ans;
  int i, tot = 1, tmp, j;
  scanf("%lld %lld %lld", &n, &a, &b);
  for (i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &x, &v[i].first, &v[i].second);
  }
  sort(v, v + n);
  for (i = 0; i < n; i++) {
    b = v[i].second - v[i].first * a;
    p = make_pair(a, b);
    tmp = mm[p];
    if (tmp == 0) {
      mm[p] = tot;
      tmp = tot++;
    }
    st[tmp].push_back(1);
    while (i + 1 < n && v[i] == v[i + 1]) {
      i++;
      st[tmp].back()++;
    }
    sum[tmp] += st[tmp].back();
  }
  ans = 0;
  for (i = 1; i < tot; i++) {
    for (j = 0; j < st[i].size(); j++) {
      ans += st[i][j] * (sum[i] - st[i][j]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
