#include <bits/stdc++.h>
using namespace std;
typedef struct _Point {
  long long x, vx, vy;
  _Point() : x(0), vx(0), vy(0) {}
} Point;
ostream& operator<<(ostream& os, Point& p) {
  os << p.vx << " " << p.vy;
  return os;
}
bool myComp(Point p1, Point p2) { return p1.vy < p2.vy; }
long long different_pairs(vector<long long>& v) {
  long long res = 0;
  set<long long> s(v.begin(), v.end());
  map<long long, long long> m;
  for (auto au = s.begin(); au != s.end(); au++) {
    m.insert(pair<long long, long long>(*au, 0));
  }
  for (auto au = v.begin(); au != v.end(); au++) {
    m[*au]++;
  }
  vector<long long> groups;
  for (auto au = m.begin(); au != m.end(); au++) {
    groups.push_back(au->second);
  }
  long long count = 0;
  for (auto au = groups.begin(); au != groups.end(); au++) {
    res += (*au) * count;
    count += *au;
  }
  return res;
}
int main() {
  long long n;
  long long a, b;
  cin >> n >> a >> b;
  vector<Point> points(n);
  for (long long i = 0; i < n; i++) {
    cin >> points.at(i).x >> points.at(i).vx >> points.at(i).vy;
  }
  for (long long i = 0; i < n; i++) {
    long long x = points.at(i).vx + points.at(i).vy * a;
    long long y = -points.at(i).vx * a + points.at(i).vy;
    points.at(i).vx = x;
    points.at(i).vy = y;
  }
  sort(points.begin(), points.end(), myComp);
  for (long long i = 0; i < n; i++) {
  }
  set<long long> vYvalues;
  for (long long i = 0; i < n; i++) {
    vYvalues.insert(points.at(i).vy);
  }
  map<long long, vector<long long> > sortedVxmap;
  for (auto au = vYvalues.begin(); au != vYvalues.end(); au++) {
    sortedVxmap.insert(
        pair<long long, vector<long long> >(*au, vector<long long>()));
  }
  for (auto au = points.begin(); au != points.end(); au++) {
    sortedVxmap.at(au->vy).push_back(au->vx);
  }
  long long res = 0;
  for (auto au = sortedVxmap.begin(); au != sortedVxmap.end(); au++) {
    res += different_pairs(au->second);
  }
  cout << 2 * res << endl;
  return 0;
}
