#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double EPS = 1e-9;
const int inf = 1e9;
const double PI = 3.1415926535897932384626433832795;
const int N = 1 * 1e5 + 5;
map<pair<long long, long long>, int> mp;
map<long long, int> v;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x, vx, vy;
    cin >> x >> vx >> vy;
    ans += v[a * vx - vy]++ - mp[{vx, vy}]++;
  }
  cout << 2 * ans;
  return 0;
}
