#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, a, b;
  cin >> n >> a >> b;
  long long x, vx, vy, ans = 0;
  map<long long, long long> inter;
  map<pair<long long, long long>, long long> parallel;
  for (int i = 0; i < n; i++) {
    cin >> x >> vx >> vy;
    inter[a * vx - vy]++;
    parallel[{vx, vy}]++;
  }
  for (auto in : inter) ans += in.second * (in.second - 1);
  for (auto pa : parallel) ans -= pa.second * (pa.second - 1);
  cout << ans << "\n";
}
