#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long c[N];
map<long long, int> cnt;
map<pair<long long, long long>, int> m;
int main() {
  int n;
  long long a, b, x, vx, vy, ans1 = 0, ans2 = 0;
  scanf("%d%lld%lld", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld%lld", &x, &vx, &vy);
    ans1 += cnt[a * vx - vy]++;
    ans2 += m[make_pair(vx, vy)]++;
  }
  printf("%lld\n", 2 * (ans1 - ans2));
  return 0;
}
