#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int N = 2e5 + 5;
long long p[N], vx[N];
map<long long, int> mp;
map<pair<long long, long long>, int> mp2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  long long a, b, x, vy;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> x >> vx[i] >> vy;
    p[i] = a * vx[i] - vy;
    mp[p[i]]++;
    mp2[{p[i], vx[i]}]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += mp[p[i]];
    ans -= mp2[{p[i], vx[i]}];
  }
  cout << ans;
  return 0;
}
