#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
map<long long, map<pair<long long, long long>, long long> > comp;
map<long long, long long> cnt;
set<pair<long long, long long> > ab;
int main() {
  cin >> n >> a >> b;
  long long ans = 0;
  while (n--) {
    long long x, vx, vy;
    cin >> x >> vx >> vy;
    cnt[a * vx - vy]++;
    comp[a * vx - vy][{vx, vy}]++;
    ans += cnt[a * vx - vy] - comp[a * vx - vy][{vx, vy}];
  }
  cout << 2 * ans << '\n';
}
