#include <bits/stdc++.h>
using namespace std;
int n;
list<int> adj[402];
vector<bool> vis;
unordered_map<string, int> dict;
stack<int> nextStep;
int maxv = INT_MIN;
int ind = 1;
int DFS(int startNode) {
  int cnt = 1;
  vis[startNode] = true;
  nextStep.push(startNode);
  while (nextStep.size()) {
    startNode = nextStep.top();
    nextStep.pop();
    for (auto it : adj[startNode]) {
      if (!vis[it]) {
        vis[it] = 1;
        nextStep.push(it);
        cnt++;
      }
    }
  }
  return cnt;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string x, y, c;
    cin >> x;
    cin >> c;
    cin >> y;
    transform(x.begin(), x.end(), x.begin(), ::tolower);
    transform(y.begin(), y.end(), y.begin(), ::tolower);
    if (dict.find(x) == dict.end()) dict[x] = ind++;
    if (dict.find(y) == dict.end()) dict[y] = ind++;
    adj[dict[x]].push_back(dict[y]);
  }
  vis.resize(ind + 1);
  for (int i = 1; i <= ind; i += 1) {
    fill(vis.begin(), vis.end(), false);
    if (!vis[i]) maxv = max(maxv, DFS(i));
  }
  cout << maxv;
  return 0;
}
