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