#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
map<long long, int> G;
map<long long, map<long long, int> > multiMap;
int main() {
  long long i, j, k, f1, f2, f3, f4, t1, t2, t3, t4;
  long long n, m, T;
  long long a, b;
  cin >> n >> a >> b;
  m = 0;
  for (i = 1; i <= n; i++) {
    cin >> t1 >> t2 >> t3;
    f1 = a * t2 - t3;
    m += G[f1] * 2;
    m -= 2 * multiMap[t2][t3];
    multiMap[t2][t3]++;
    G[f1]++;
  }
  cout << m << endl;
  return 0;
}
