#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
map<long long, int> mp;
map<pair<long long, long long>, int> ix;
map<pair<long long, long long>, int> iy;
map<pair<pair<long long, long long>, long long>, int> ico;
long long res = 0, a, b, x, vx, vy;
int n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> x >> vx >> vy;
    long long d = vy - a * vx;
    res += mp[vy - a * vx]++;
    res -= ix[pair<long long, long long>(vx, d)]++;
    res -= iy[pair<long long, long long>(vy, d)]++;
    res += ico[pair<pair<long long, long long>, long long>(
        pair<long long, long long>(vx, vy), d)]++;
  }
  res *= 2;
  cout << res << '\n';
  return 0;
}
