#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
  return f ? s : -s;
}
inline int getc() {
  char c = getchar();
  while (c < 'a' || c > 'z') c = getchar();
  return c - 'a';
}
int n, tr[400010][26], cnt;
int ans[300010];
int merge(int x, int y) {
  if (x == 0 || y == 0) return x + y;
  int tmp = ++cnt;
  for (register int i = 0; i < 26; ++i) tr[tmp][i] = merge(tr[x][i], tr[y][i]);
  return tmp;
}
void dfs(int x, int dep) {
  int now = n + 1;
  cnt = now;
  for (register int i = 0; i < 26; ++i)
    if (tr[x][i]) now = merge(now, tr[x][i]);
  ans[dep] += cnt - n - 1;
  for (register int i = 0; i < 26; ++i)
    if (tr[x][i]) dfs(tr[x][i], dep + 1);
}
int main() {
  n = read();
  for (register int i = 1; i < n; ++i) {
    int x = read(), y = read(), c = getc();
    tr[x][c] = y;
  }
  dfs(1, 1);
  int Max = -1, pos = 0;
  for (register int i = 1; i <= n; ++i)
    if (Max < ans[i]) Max = ans[i], pos = i;
  printf("%d\n%d\n", n - Max, pos);
  return 0;
}
