#include <bits/stdc++.h>
using namespace std;
long long v[200100];
pair<long long, long long> vv[200100];
map<long long, long long> M;
map<pair<long long, long long>, long long> MM;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    long long x, vx, vy;
    cin >> x >> vx >> vy;
    vx *= a;
    v[i] = vy - vx;
    vv[i] = {vx, vy};
    MM[vv[i]]++;
    M[v[i]]++;
  }
  long long cont = 0;
  for (int i = 1; i <= n; i++) {
    cont += M[v[i]] - MM[vv[i]];
  }
  cout << cont;
  return 0;
}
