#include <bits/stdc++.h>
const int N = 6e5 + 7;
int n, cnt, c[N][26], a[N];
int mg(int x, int y) {
  if (!x || !y) return x + y;
  int now = ++cnt;
  for (int i = 0; i <= 25; ++i) c[now][i] = mg(c[x][i], c[y][i]);
  return now;
}
void dfs(int x, int d) {
  int now = n + 1;
  cnt = n + 1;
  for (int i = 0; i <= 25; ++i)
    if (c[x][i]) now = mg(now, c[x][i]);
  a[d] += cnt - n - 1;
  for (int i = 0; i <= 25; ++i)
    if (c[x][i]) dfs(c[x][i], d + 1);
}
int main() {
  std::cin >> n;
  int x, y, ans = 0, as = 0;
  char w;
  for (int i = 2; i <= n; ++i) {
    std::cin >> x >> y >> w;
    c[x][w - 'a'] = y;
  }
  dfs(1, 1);
  for (int i = 1; i <= n; ++i)
    if (a[i] > ans) as = i, ans = a[i];
  printf("%d\n%d\n", n - ans, as);
}
