#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int ch[maxn][26], cnt, a[maxn], N;
int merge(int u, int v) {
  if (!u || !v) return u | v;
  int now = ++cnt;
  for (int i = 0; i <= 25; i++) ch[now][i] = merge(ch[u][i], ch[v][i]);
  return now;
}
void dfs(int u, int d) {
  int now = N + 1;
  cnt = N + 1;
  for (int i = 0; i <= 25; i++)
    if (ch[u][i]) now = merge(now, ch[u][i]);
  a[d] += cnt - N - 1;
  for (int i = 0; i <= 25; i++)
    if (ch[u][i]) dfs(ch[u][i], d + 1);
}
int main() {
  int u, v;
  char c[3];
  scanf("%d", &N);
  for (int i = 1; i <= N - 1; i++) {
    scanf("%d%d%s", &u, &v, c + 1);
    ch[u][c[1] - 'a'] = v;
  }
  dfs(1, 1);
  int ans = 0, p = 0;
  for (int i = 1; i <= N; i++)
    if (a[i] > ans) ans = a[i], p = i;
  printf("%d\n%d\n", N - ans, p);
  return 0;
}
