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