#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;
struct line{ int p,a,b; };

inline int intersect_inside(line m, line n)
{
    if((ll)m.a*(n.a+n.b) > (ll)n.b*(m.a+m.b)) return 1;
    return 0;
}

int main()
{
    int n;
    scanf(" %d", &n);

    vector<line> l(n);
    rep(i,n)
    {
        scanf(" %d %d %d", &l[i].p, &l[i].a, &l[i].b);
        int G=__gcd(l[i].a,l[i].b);
        l[i].a/=G;
        l[i].b/=G;
    }

    int two=0,three=0;

    rep(i,n)rep(j,i)if(l[i].p!=l[j].p) two+=intersect_inside(l[i],l[j]);

    set<pi> s[3];
    rep(i,n) s[l[i].p].insert(pi(l[i].a,l[i].b));

    for(const auto &X:s[0])
    {
        if(X.fi>=X.se && s[1].count(X) && s[2].count(X)) ++three;

        if(X.fi!=X.se)
        {
            pi revX(X.se,X.fi);
            if(s[1].count(revX) && s[2].count(revX)) ++three;
            if(s[1].count(X) && s[2].count(revX)) ++three;
            if(s[1].count(revX) && s[2].count(X)) ++three;
        }
    }


    printf("%d\n", 1+n+two+three);
    return 0;
}