#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
const int maxn = 200005;
struct G {
  long long x, y, vx, vy;
  long long dist;
} gh[maxn];
bool cmp(const G& g1, const G& g2) {
  if (g1.dist < g2.dist)
    return true;
  else if (g1.dist > g2.dist)
    return false;
  else if (g1.vx < g2.vx) {
    return true;
  } else if (g1.vx > g2.vx) {
    return false;
  } else {
    return g1.vy < g2.vy;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> gh[i].x >> gh[i].vx >> gh[i].vy;
    gh[i].y = gh[i].x * a + b;
    gh[i].dist = gh[i].vy - gh[i].vx * a;
  }
  sort(gh, gh + n, cmp);
  long long start, en = 0;
  long long cnt, all;
  long long result = 0;
  for (int i = 0; i < n;) {
    start = i;
    while (i < n && gh[i].dist == gh[start].dist) {
      i++;
    }
    all = i - start;
    cnt = 1;
    for (int j = start + 1; j < i; j++) {
      if (gh[j].vx == gh[j - 1].vx) {
        cnt++;
      } else {
        result += cnt * (all - cnt);
        cnt = 1;
      }
    }
    result += cnt * (all - cnt);
  }
  cout << result << endl;
}
