#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;
int cnt[MAXN];
ll dp[MAXN];
bool vis[MAXN], used[MAXN];
vector<int> G[MAXN];
vector<ll> V;
set<ll> S;
map<ll, pair<map<ll, int>, int>> M;
stack<ll> St;
queue<ll> Q;
struct ghost {
  ll x, vx, vy;
};
ghost tab[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(13) << fixed;
  int n;
  ll a, b;
  cin >> n >> a >> b;
  ll res = 0;
  for (int i = 1; i <= n; i++) {
    ll x, vx, vy;
    cin >> x >> vx >> vy;
    tab[i] = {x, vx, vy};
  }
  for (int i = 1; i <= n; i++) {
    ll vx = tab[i].vx, vy = tab[i].vy;
    res += M[a * vx - vy].second - M[a * vx - vy].first[vx];
    M[a * vx - vy].second++;
    M[a * vx - vy].first[vx]++;
  }
  cout << 2 * res << "\n";
}
