#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
// avoid unordered_map and unordered_set!!!
#include <vector>
#include <utility>

using namespace std;

using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using pi64 = pair<i64, i64>;

#define vec vector
#define let const
#define DRi64(x) i64 x; cin >> x;
#define DRS(x) string x; cin >> x;
#define DRVi64(v, n) vec<i64> v(n); { for (i64 i = 0; i < n; ++i) { cin >> v[i]; }}
#define DRpi64(x) pi64 x; cin >> x.first >> x.second;

#ifdef DEBUG
#define P(x) cerr << x << "\n"
#else
#define P(x)
#endif

constexpr i64 MAXN = 3*100*1000LL+5LL;
constexpr i64 MOD = 1000000007LL;
constexpr i64 INF64 = MOD * MOD;

int
main()
{
    ios_base::sync_with_stdio(false);
    // fast io: see 1423K
    cin.tie(nullptr);
    cout.tie(nullptr);

    DRS(S);
    assert(S.size() == 10);
    i64 acc = 0;
    for (i64 a = 0; a <= 9; ++a)
    {
        if (S[a] == 'x')
        {
            continue;
        }
        for (i64 b = 0; b <= 9; ++b)
        {
            if (S[b] == 'x')
            {
                continue;
            }
            for (i64 c = 0; c <= 9; ++c)
            {
                if (S[c] == 'x')
                {
                    continue;
                }
                for (i64 d = 0; d <= 9; ++d)
                {
                    if (S[d] == 'x')
                    {
                        continue;
                    }
                    bool ok = true;
                    for (i64 i = 0; i < S.size() && ok; ++i)
                    {
                        if (S[i] != 'o')
                        {
                            continue;
                        }
                        ok &= a == i || b == i || c == i || d == i;
                    }
                    acc += ok;
                }
            }
        }
    }
    cout << acc << "\n";

    return 0;
}

/*                             हरे कृष्ण हरे कृष्ण कृष्ण कृष्ण हरे हरे
                                  हरे राम हरे राम राम राम हरे हरे                                     */
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define pob pop_back
typedef long long int lli;
#define test lli t; cin>>t; while(t--)
#define ff first
#define ss second
#define F(n) for(lli i=0;i<n;i++)
#define pf pop_front
#define lb lower_bound
#define ub upper_bound
#define setbits(x)  __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x)
#define bs binary_search
#define all(x) x.begin(),x.end()
#define nl "\n"
#define loop(i,s,n) for(lli i=s;i<n;i++)
#define pp(a)  for(auto x : a)  cout<<x<<" ";  cout<<nl;
#define mem(arr,x) memset(arr,x,sizeof(arr))
#define mod 1000000007
#define inf 1e18
#define tt(n) cin>>n; lli a[n]; loop(i,0,n) cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ps(x,y) fixed<<setprecision(y)<<x

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    lli n,l,r,ans=0,j,i;
    cin>>n;
    lli a[n];
    vector<pair<lli,lli>> v;
    loop(i,0,n) 
    {
        cin>>a[i]>>l>>r;
        v.pb(make_pair(l,r));
    }
    loop(i,0,n)
    {
        loop(j,i+1,n)
        {
            if(v[i].ff==v[j].ff || v[i].ss==v[j].ss)
            {
                //cout<<i<<" "<<j<<nl;
                if(v[i].ss<v[j].ss) ans++;
                else if(v[i].ss>v[j].ss) ans++;
                else ans++;
            }
            else if(v[i].ff>v[j].ff)
            {
                if(v[j].ss>v[i].ff) {ans++;}
                else if(v[j].ss==v[i].ff) 
                {
                    if((a[j]==1 && a[i]==1) || (a[j]==1 && a[i]==2) || (a[j]==3 && a[i]==2) || (a[j]==3 && a[i]==1)) ans++;
                }
            }
            else
            {
                if(v[i].ss>v[j].ff) {ans++;}
                else if(v[i].ss==v[j].ff) 
                {
                    if((a[i]==1 && a[j]==1) || (a[i]==1 && a[j]==2) || (a[i]==3 && a[j]==2) || (a[i]==3 && a[j]==1)) ans++;
                }
            }
        }
    }
    cout<<ans;
return 0;
}