#include <bits/stdc++.h>
using namespace std;
int n, u, v, cnt, Del[600005];
char c[10];
struct Tree {
  int ch[26];
} t[600005];
int merge(int x, int y, int d) {
  if (!x || !y) return x + y;
  int New = ++cnt;
  Del[d]++;
  for (int i = 0; i < 26; i++) t[New].ch[i] = merge(t[x].ch[i], t[y].ch[i], d);
  return New;
}
void dfs(int u, int d) {
  int rt = 0;
  for (int i = 0; i < 26; i++) rt = merge(rt, t[u].ch[i], d);
  if (rt) Del[d]++;
  for (int i = 0; i < 26; i++)
    if (t[u].ch[i]) dfs(t[u].ch[i], d + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d%s", &u, &v, &c);
    t[u].ch[c[0] - 'a'] = v;
  }
  cnt = n;
  dfs(1, 1);
  printf("%d\n%d", n - *max_element(Del, Del + n),
         (int)(max_element(Del, Del + n) - Del));
}
