#include <bits/stdc++.h>
using namespace std;
int t[610000][26];
int ans[310000], pos;
int n, num, nn, v;
int merge(int x, int y) {
  if (x == 0 || y == 0) return x + y;
  int now = ++nn;
  v++;
  for (int i = 0; i < 26; i++) t[now][i] = merge(t[x][i], t[y][i]);
  return now;
}
void dfs(int x, int depth) {
  nn = n + 1;
  int now = nn;
  v = 0;
  for (int i = 0; i < 26; i++) now = merge(now, t[x][i]);
  ans[depth] += v;
  for (int i = 0; i < 26; i++)
    if (t[x][i]) dfs(t[x][i], depth + 1);
}
int x, y;
char z;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) scanf("%d %d %c", &x, &y, &z), t[x][z - 'a'] = y;
  dfs(1, 1);
  for (int i = 1; i <= n; i++)
    if (n - ans[pos] > n - ans[i]) pos = i;
  printf("%d\n", n - ans[pos]);
  printf("%d\n", pos);
  return 0;
}
