#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  for (auto v : V) os << v << " ";
  return cout << "";
}
template <class T>
ostream& operator<<(ostream& os, set<T> S) {
  for (auto s : S) os << s << " ";
  return cout << "";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << P.first << " " << P.second;
}
const long long mod = 1e9 + 7;
long long inv(long long i) {
  if (i == 1) return 1;
  return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long pwr(long long a, long long b) {
  a %= mod;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, a, b;
  cin >> n >> a >> b;
  pair<int, pair<int, int>> v[n];
  map<pair<long long, long long>, long long> make_pair;
  map<long long, long long> m;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second.first >> v[i].second.second;
    m[a * v[i].second.first - v[i].second.second]++;
  }
  long long ans = 0;
  for (auto u : m) {
    ans += (u.second - 1) * u.second;
  }
  for (int i = 0; i < n; i++) {
    if (v[i].second.first == 0 or v[i].second.second == 0) {
    } else {
      long long g = gcd(abs(v[i].second.first), abs(v[i].second.second));
      v[i].second.first /= g;
      v[i].second.second /= g;
    }
    make_pair[v[i].second]++;
  }
  for (auto u : make_pair) {
    ans -= (u.second * (u.second - 1));
  }
  cout << (ans) << "\n";
}
