#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio;
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, a, b;
  cin >> n >> a >> b;
  long long x, Vx, Vy;
  map<long long, long long> ans;
  long long res = 0;
  map<pair<long long, long long>, long long> check;
  for (long long i = 0; i < n; i++) {
    cin >> x >> Vx >> Vy;
    if (!ans.count(a * Vx - Vy)) {
      ans[a * Vx - Vy] = 1;
      check[make_pair(Vx, Vy)] = 1;
    } else {
      res = res + ans[a * Vx - Vy] - check[make_pair(Vx, Vy)];
      ans[a * Vx - Vy] += 1;
      check[make_pair(Vx, Vy)] += 1;
    }
  }
  cout << res * 2;
}
