#include <bits/stdc++.h>
using namespace std;
const long long maxn = 32000;
const long long maxm = 1e9;
const long long mod = 1000000007;
long long n, pare, ans;
map<long long, int> m;
map<pair<int, int>, int> para;
int main() {
  long long a, b, x, vx, vy, k;
  cin >> n >> a >> b;
  while (n--) {
    scanf("%lld%lld%lld", &x, &vx, &vy);
    k = a * vx - vy;
    ans += m[k];
    m[k]++;
    pare += para[make_pair(vx, vy)];
    para[make_pair(vx, vy)]++;
  }
  ans = (ans - pare) * 2;
  cout << ans << endl;
  return 0;
}
