#include <bits/stdc++.h>
using namespace std;
int n, val[300005], h[300005];
int a[2 * 300005][26], tot, ans[300005];
int mer(int x, int y) {
  if (x == 0 || y == 0) return x + y;
  int z = ++tot;
  for (int i = 0; i < 26; i++) a[z][i] = mer(a[x][i], a[y][i]);
  return z;
}
void dfs(int k, int d) {
  tot = n + 1;
  int b = tot;
  for (int i = 0; i < 26; i++) b = mer(b, a[k][i]);
  ans[d] += tot - n - 1;
  for (int i = 0; i < 26; i++)
    if (a[k][i]) dfs(a[k][i], d + 1);
}
int main() {
  int i, j, x, y;
  char z;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d %d %c", &x, &y, &z);
    a[x][z - 'a'] = y;
  }
  dfs(1, 1);
  for (i = 1, x = y = 0; i <= n; i++)
    if (x < ans[i]) {
      y = i;
      x = ans[i];
    }
  printf("%d\n%d\n", n - x, y);
}
