#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
const int mod = 1e9 + 7;
const int mxn = 1e5 + 9;
const long double eps = 1e-9;
long long vx, vy;
map<long long, long long> cnt;
map<pair<long long, long long>, long long> mp;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long i, j, k, n, m, a, b, ans = 0;
  cin >> n >> a >> b;
  for (i = 1; i <= n; i++) {
    cin >> k >> vx >> vy;
    ans += cnt[a * vx - vy] - mp[{vx, vy}];
    cnt[a * vx - vy]++;
    mp[{vx, vy}]++;
  }
  cout << ans * 2 << "\n";
  return 0;
}
