#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long MOD = (int)1e9 + 7;
const long long MOR = (int)1e9 + 31;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int MAXN = (int)6e5 + 5;
long long a[MAXN], pr[MAXN];
long long sc(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first * b.first + a.second * b.second;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  vector<pair<long long, long long>> line(0);
  map<long long, vector<pair<long long, long long>>> per;
  for (int i = 0; i < n; i++) {
    long long x0, y0, vx0, vy0;
    cin >> x0 >> vx0 >> vy0;
    y0 = a * x0 + b;
    long long x1 = x0 + vx0, dkslfgkgs = y0 + vy0;
    long long b1 = dkslfgkgs - a * x1;
    per[b1].push_back({vx0, vy0});
  }
  long long answ = 0;
  map<pair<long long, long long>, long long> cnt;
  for (auto w : per) {
    cnt.clear();
    long long sum = 0;
    for (auto p : w.second) cnt[p]++, sum++;
    for (auto p : cnt) {
      answ += p.second * (sum - p.second);
    }
  }
  cout << answ;
}
