#include <bits/stdc++.h>
using namespace std;
int n, a, b, uu, vv, ww;
map<long long, int> mp1;
map<pair<int, int>, int> mp2;
int main() {
  cin >> n >> a >> b;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &uu, &vv, &ww);
    long long tmp1 = (long long)a * vv - ww;
    pair<int, int> tmp2 = make_pair(vv, ww);
    ans += mp1[tmp1] - mp2[tmp2];
    mp1[tmp1]++;
    mp2[tmp2]++;
  }
  cout << ans * 2;
  return 0;
}
