#include <bits/stdc++.h>
using namespace std;
const long long N = 1e9 + 7;
map<long long, long long> mp1, mp2;
int main() {
  long long a, b, x, y, tem, ans;
  int n;
  while (scanf("%d%lld%lld", &n, &a, &b) != EOF) {
    ans = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%lld%lld%lld", &tem, &x, &y);
      mp1[y - a * x]++;
      mp2[x * N + y]++;
    }
    map<long long, long long>::iterator it;
    ans = 0;
    for (it = mp1.begin(); it != mp1.end(); it++) {
      tem = it->second;
      ans += tem * (tem - 1);
    }
    for (it = mp2.begin(); it != mp2.end(); it++) {
      tem = it->second;
      ans -= tem * (tem - 1);
    }
    printf("%I64d\n", ans);
  }
}
