#include <bits/stdc++.h>
using namespace std;
char xB[1 << 15], *xS = xB, *xTT = xB;
template <typename T>
inline void rd(T& xaa) {
  char xchh;
  T f = 1;
  xaa = 0;
  while (xchh = (xS == xTT && (xTT = (xS = xB) + fread(xB, 1, 1 << 15, stdin),
                               xS == xTT)
                     ? 0
                     : *xS++),
         !((xchh >= '0' && xchh <= '9') || (xchh == '-')))
    ;
  if (xchh == '-') {
    f = -1;
    xchh = (xS == xTT &&
                    (xTT = (xS = xB) + fread(xB, 1, 1 << 15, stdin), xS == xTT)
                ? 0
                : *xS++);
  }
  xaa = xchh - '0';
  while (xchh = (xS == xTT && (xTT = (xS = xB) + fread(xB, 1, 1 << 15, stdin),
                               xS == xTT)
                     ? 0
                     : *xS++),
         ((xchh >= '0' && xchh <= '9') || (xchh == '-')))
    xaa = xaa * 10 + xchh - '0';
  xaa *= f;
  return;
}
long long geta(long long x, long long y, long long a, long long b) {
  return x * a + y * b;
}
long long getb(long long x, long long y, long long a, long long b) {
  return x * b - y * a;
}
int n;
long long a, b, res;
int main() {
  rd(n);
  rd(a);
  rd(b);
  map<long long, vector<long long> > val;
  for (int i = 1; i <= n; i++) {
    long long e, x, y;
    rd(e);
    rd(x);
    rd(y);
    long long px = geta(x, y, 1, a), py = getb(x, y, 1, a);
    val[py].push_back(px);
  }
  long long res = 0;
  for (map<long long, vector<long long> >::iterator it = val.begin();
       it != val.end(); it++) {
    vector<long long>& tv = it->second;
    sort(tv.begin(), tv.end());
    long long nv = 0, nc = 0;
    bool st = 0;
    int len = static_cast<int>(tv.size());
    for (vector<long long>::iterator it1 = tv.begin(); it1 != tv.end(); it1++) {
      if (!st) {
        nv = *it1;
        nc = 1;
        st = 1;
      } else {
        if (*it1 == nv)
          nc++;
        else {
          res += nc * (len - nc);
          nv = *it1;
          nc = 1;
        }
      }
    }
    res += nc * (len - nc);
  }
  cout << res << endl;
  return 0;
}
