#include <bits/stdc++.h>
using namespace std;
long long n, aa, b;
struct node {
  long long x, vx, vy;
  long long y;
} a[200000 + 5];
map<long long, long long> mp;
map<pair<long long, long long>, long long> mmp;
int main() {
  cin >> n >> aa >> b;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].vx >> a[i].vy;
    a[i].y = a[i].x * aa + b;
  }
  for (int i = 1; i <= n; i++) {
    mp[aa * a[i].vx - a[i].vy]++;
    mmp[{a[i].vx, a[i].vy}]++;
  }
  long long ans = 0;
  for (auto i : mp) {
    ans += i.second * (i.second - 1);
  }
  for (auto i : mmp) {
    ans -= i.second * (i.second - 1);
  }
  cout << ans << endl;
}
