#include <bits/stdc++.h>   using namespace std;   const int N = 6e1;   map<string, int> mp;   int n;   int answer = 1;   string To(string a) {     for (int i = 0; i < a.size(); i++)       if (a[i] >  Z ) a[i] = a[i] - 32;     return a;   }   int main() {     mp[ POLYCARP ] = 1;     cin >> n;     for (int i = 0; i < n; i++) {       string n1, r, n2;       cin >> n1 >> r >> n2;       n1 = To(n1);       n2 = To(n2);       mp[n1] = mp[n2] + 1;       answer = max(answer, mp[n1]);     }     cout << answer;   }   