#include <bits/stdc++.h>
using namespace std;
struct line {
  long long x = 0, vx = 0, vy = 0;
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  vector<line> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].x >> v[i].vx >> v[i].vy;
  }
  long long ans = 0;
  map<long long, long long> need;
  map<pair<long long, long long>, long long> was;
  for (int i = 0; i < n; i++) {
    ans += need[a * v[i].vx - v[i].vy] - was[{v[i].vx, v[i].vy}];
    need[a * v[i].vx - v[i].vy]++;
    was[{v[i].vx, v[i].vy}]++;
  }
  cout << ans * 2 << endl;
}
