#include <bits/stdc++.h>
using namespace std;
const long long N = 1e+6 + 5;
long long big = 1e+18 + 3;
long long mod = 1e+9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  map<long long, set<pair<long long, long long> > > types;
  map<pair<long long, long long>, long long> freq;
  map<long long, long long> totSlopeFreq;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long xco, vx, vy;
    cin >> xco >> vx >> vy;
    totSlopeFreq[(vy - a * vx)]++;
    types[(vy - a * vx)].insert({vx, vy});
    freq[{vx, vy}]++;
  }
  for (auto it : types) {
    long long cur_ans =
        (totSlopeFreq[(it.first)] * (totSlopeFreq[(it.first)] - 1)) / 2;
    for (auto itr : it.second) cur_ans -= ((freq[itr] - 1) * (freq[itr])) / 2;
    cur_ans *= 2;
    ans += cur_ans;
  }
  cout << ans << "\n";
}
