#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
const int maxn = 1e6 + 233;
int ch[maxn][26];
int ans[maxn], tot, n, fa[maxn];
int merge(int x, int y, int z) {
  if (!x || !y) return x + y;
  int now = ++tot;
  ans[z]++;
  for (register int i = (0); i < int(26); ++i)
    ch[now][i] = merge(ch[x][i], ch[y][i], z);
  return now;
}
void dfs(int u, int dep) {
  int rt = 0;
  tot = n;
  for (int i = 0; i < 26; ++i) {
    if (ch[u][i]) {
      rt = merge(rt, ch[u][i], dep);
    }
  }
  if (rt) ans[dep]++;
  for (int i = 0; i < 26; ++i)
    if (ch[u][i]) dfs(ch[u][i], dep + 1);
}
int main() {
  n = read();
  for (register int i = (1); i < int(n); ++i) {
    int a = read(), b = read();
    char c = getchar();
    while (c < 'a' || c > 'z') c = getchar();
    ch[a][c - 'a'] = b;
    fa[b] = a;
  }
  int root = -1;
  for (register int i = (1); i <= int(n); ++i)
    if (!fa[i]) root = i;
  memset(ans, 0, sizeof(ans));
  dfs(root, 1);
  int Answ = n, answ = 0;
  for (register int i = (1); i <= int(n); ++i) {
    if (Answ > n - ans[i]) {
      answ = i;
      Answ = n - ans[i];
    }
  }
  writeln(Answ);
  writeln(answ);
  return 0;
}
