#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 50;
const int inf = 1e9;
struct node {
  int x, y;
  node(int _x, int _y) {
    x = _x;
    y = _y;
  }
  friend bool operator<(const node &a, const node &b) {
    if (a.x != b.x) return a.x < b.x;
    return a.y < b.y;
  }
};
int vx[maxn], vy[maxn];
map<long long, int> cnt;
map<node, int> same_cnt;
int n, a, b;
inline long long f(int i) { return vy[i] - (long long)a * vx[i]; }
int main() {
  scanf("%d %d %d", &n, &a, &b);
  for (int i = 1; i <= n; ++i) {
    int x;
    scanf("%d %d %d", &x, &vx[i], &vy[i]);
    if (!cnt.count(f(i))) cnt[f(i)] = 0;
    cnt[f(i)]++;
    if (!same_cnt.count(node(vx[i], vy[i]))) same_cnt[node(vx[i], vy[i])] = 0;
    same_cnt[node(vx[i], vy[i])]++;
  }
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int t1 = cnt[f(i)];
    int t2 = same_cnt[node(vx[i], vy[i])];
    ans += t1 - t2;
  }
  cout << ans << endl;
  return 0;
}
