#include <bits/stdc++.h>
using namespace std;
int sz[300010], a[300010 << 1][30];
int n, f[300010], dep[300010], tot, ans;
int merge(int x, int y) {
  if (!((long long)x * y)) return x + y;
  int i, p = ++tot;
  sz[p] = 1;
  for (i = 0; i < 26; i++) {
    a[p][i] = merge(a[x][i], a[y][i]);
    sz[p] += sz[a[p][i]];
  }
  return p;
}
void dfs(int x, int dad) {
  int i, p = 0;
  dep[x] = dep[dad] + 1;
  sz[x] = 1;
  for (i = 0; i < 26; i++)
    if (a[x][i]) {
      dfs(a[x][i], x);
      sz[x] += sz[a[x][i]];
    }
  tot = n;
  for (i = 0; i < 26; i++)
    if (a[x][i]) p = merge(p, a[x][i]);
  f[dep[x]] += sz[x] - max(sz[p], 1);
}
int main() {
  char s[30];
  int i, x, y;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d%d%s", &x, &y, s);
    a[x][s[0] - 'a'] = y;
  }
  ans = 1;
  dfs(1, 0);
  for (i = 2; i <= n; i++)
    if (f[i] > f[ans]) ans = i;
  printf("%d\n%d\n", n - f[ans], ans);
}
