#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
unordered_map<long long, int> cnt;
unordered_map<long long, unordered_map<int, int> > cnt_x;
unordered_map<long long, unordered_map<int, int> > cnt_y;
unordered_map<long long, unordered_map<long long, int> > cnt_xy;
inline long long C(int n) { return (long long)n * (n - 1) / 2; }
int main(int argc, char *argv[]) {
  int n, a, b;
  map<long long, int> cnt;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 0; i < (n); ++i) {
    int x, vx, vy;
    scanf("%d%d%d", &x, &vx, &vy);
    long long z = vy - (long long)a * vx, vxy = ((long long)vx << 32 | vy);
    ++cnt[z], ++cnt_x[z][vx], ++cnt_y[z][vy], ++cnt_xy[z][vxy];
  }
  long long ret = 0;
  for (auto &i : cnt) ret += C(i.second);
  for (auto &i : cnt_x)
    for (auto &j : i.second) ret -= C(j.second);
  for (auto &i : cnt_y)
    for (auto &j : i.second) ret -= C(j.second);
  for (auto &i : cnt_xy)
    for (auto &j : i.second) ret += C(j.second);
  printf("%lld\n", ret * 2);
  return 0;
}
