#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pir;
int n, a, b, uu, vv, ww;
map<ll,int> mp1;
map<pir,int> mp2;
int main(){
cin>>n>>a>>b;
ll ans=0;
for(int i=1; i<=n; i++){
scanf("%d %d %d", &uu, &vv, &ww);
ll tmp1 = (ll)a * vv - ww;
pir tmp2=make_pair(vv, ww);
ans += mp1[tmp1] - mp2[tmp2];
mp1[tmp1]++;
mp2[tmp2]++;
}
cout<<ans*2<<endl;
return 0;
}