#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
map<long long, int> mp1;
map<pair<int, int>, int> mp2;
int main() {
  ios::sync_with_stdio(false);
  long long a, b, n, ans = 0;
  cin >> n >> a >> b;
  while (n--) {
    long long x, X, Y;
    cin >> x >> X >> Y;
    long long t1 = ++mp1[a * X - Y];
    long long t2 = ++mp2[pair<int, int>(X, Y)];
    ans += 2 * t1 - 2 * t2;
  }
  cout << ans << endl;
  return 0;
}
