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