#include <bits/stdc++.h>
const int N = 1e6 + 10;
int ch[N][30], n, cnt, a[N];
using namespace std;
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int now = ++cnt;
  for (register int i = (0); i <= (25); ++i)
    ch[now][i] = merge(ch[x][i], ch[y][i]);
  return now;
}
void dfs(int x, int dep) {
  int now = n + 1;
  cnt = n + 1;
  for (register int i = (0); i <= (25); ++i) now = merge(now, ch[x][i]);
  a[dep] += cnt - n - 1;
  for (register int i = (0); i <= (25); ++i)
    if (ch[x][i]) dfs(ch[x][i], dep + 1);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  int x, y;
  char c;
  for (register int i = (2); i <= (n); ++i)
    cin >> x >> y >> c, ch[x][c - 'a'] = y;
  dfs(1, 1);
  int ans = 0, pans = 0;
  for (register int i = (1); i <= (n); ++i)
    if (a[i] > ans) ans = a[i], pans = i;
  cout << n - a[pans] << '\n' << pans << '\n';
  return 0;
}
