#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
struct Point {
  int x, y;
  bool operator<(const Point& rhs) const {
    if (x != rhs.x)
      return x < rhs.x;
    else
      return y < rhs.y;
  }
} p[MAXN];
int n, a, b;
int x[MAXN];
unordered_map<long long, int> sum;
map<Point, int> cnt;
int main() {
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", x + i, &p[i].x, &p[i].y);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += sum[(long long)a * p[i].x - p[i].y] - cnt[p[i]];
    sum[(long long)a * p[i].x - p[i].y]++;
    cnt[p[i]]++;
  }
  printf("%lld\n", ans * 2);
  return 0;
}
