#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long cnt, a, b;
  map<long long, int> along, away;
  map<pair<long long, long long>, int> awaysl;
  cin >> cnt >> a >> b;
  long long x, vx, vy, ans = 0;
  for (int i = 0; i < cnt; i++) {
    cin >> x >> vx >> vy;
    vx *= a;
    long long diff = vx - vy;
    if (diff == 0) {
      along[vx]++;
    } else {
      pair<long long, long long> now = {diff, vx + vy};
      ans += (away[diff] - awaysl[now]) * 2;
      away[diff]++;
      awaysl[now]++;
    }
  }
  long long s = 0;
  for (auto i : along) {
    long long v = i.second;
    s += v;
    ans -= v * (v - 1);
  }
  ans += s * (s - 1);
  cout << ans << endl;
  return 0;
}
