#include <bits/stdc++.h>
using namespace std;
long long vx[200005], vy[200005], x[200005];
set<long long> s;
set<pair<long long, long long> > second;
set<pair<long long, long long> >::iterator it2;
map<pair<long long, long long>, long long> mp2;
set<long long>::iterator it;
map<long long, long long> mp;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long i, j, n, a, b, c, q, ans;
  while (cin >> n >> a >> b) {
    s.clear();
    mp.clear();
    second.clear();
    mp2.clear();
    for (i = 1; i <= n; i++) {
      cin >> x[i] >> vx[i] >> vy[i];
      second.insert({vx[i], vy[i]});
      s.insert(vy[i] - a * vx[i]);
      mp2[{vx[i], vy[i]}]++;
      mp[vy[i] - a * vx[i]]++;
    }
    ans = 0;
    for (it = s.begin(); it != s.end(); ++it) {
      c = mp[*it];
      ans += c * (c - 1);
    }
    for (it2 = second.begin(); it2 != second.end(); ++it2) {
      c = mp2[*it2];
      ans -= c * (c - 1);
    }
    cout << ans << endl;
  }
  return 0;
}
