#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int tree[N * 2][26];
int tot[N];
int n, cnt, code;
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int z = ++code;
  cnt++;
  for (int i = 0; i < 26; i++) tree[z][i] = merge(tree[x][i], tree[y][i]);
  return z;
}
void dfs(int u, int dep) {
  code = n + 1, cnt = 0;
  int rt = code;
  for (int i = 0; i < 26; i++) rt = merge(rt, tree[u][i]);
  tot[dep] += cnt;
  for (int i = 0; i < 26; i++)
    if (tree[u][i]) dfs(tree[u][i], dep + 1);
}
int main() {
  scanf("%d", &n);
  char ch;
  int u, v;
  for (int i = 1; i < n; i++) {
    scanf("%d %d %c", &u, &v, &ch);
    tree[u][ch - 'a'] = v;
  }
  dfs(1, 1);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (tot[i] > tot[ans]) ans = i;
  printf("%d\n%d\n", n - tot[ans], ans);
  return 0;
}
