#include <bits/stdc++.h>
#pragma GCC optimize(3, "inline", "Ofast")
using namespace std;
struct gg {
  long long x, y;
} node[200010];
bool cmp(gg xx, gg yy) { return xx.x == yy.x ? xx.y < yy.y : xx.x < yy.x; }
long long n, a, b, x, vx, vy, w[200010], ans;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> x >> vx >> vy;
    node[i].x = vx, node[i].y = vy;
    w[i] = a * vx - vy;
  }
  sort(node + 1, node + n + 1, cmp);
  for (int i = 1; i <= n;) {
    long long sam = 1;
    bool flag = 0;
    for (int j = i + 1; j <= n; j++) {
      if (node[j].x != node[i].x) {
        i = j;
        flag = 1;
        break;
      }
      if (node[j].y == node[i].y && node[j].x == node[i].x) sam++;
      if (node[j].y > node[i].y) {
        i = j;
        flag = 1;
        break;
      }
    }
    ans -= sam * (sam - 1);
    if (!flag) break;
  }
  sort(w + 1, w + n + 1);
  for (int i = 1; i <= n;) {
    int j = upper_bound(w + i + 1, w + n + 1, w[i]) - w;
    j--;
    if (w[j] == w[i])
      ans += (long long)(j - i + 1) * (j - i), i = j + 1;
    else
      i = j;
  }
  cout << ans;
}
