#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > g[310000];
char c;
int n, x, y, tot, ch[2 * 310000][26], ans[310000], deep[310000], son[310000],
    size[2 * 310000];
void dfs(int x, int fa, int d) {
  deep[x] = d;
  size[x] = 1;
  for (auto e : g[x]) {
    ch[x][e.second] = e.first;
    dfs(e.first, x, d + 1);
    size[x] += size[e.first];
    if (size[e.first] > size[son[x]]) son[x] = e.first;
  }
}
int merge(int x, int y) {
  if (!x || !y) return x + y;
  int t = ++tot;
  size[t] = 1;
  for (int i = 0; i < 26; i++) {
    ch[t][i] = merge(ch[x][i], ch[y][i]);
    size[t] += size[ch[t][i]];
  }
  return t;
}
void dsu(int x) {
  if (!son[x]) return;
  int root = son[x];
  tot = n;
  for (int i = 0; i < 26; i++) {
    if (!ch[x][i]) continue;
    if (ch[x][i] == son[x]) continue;
    root = merge(root, ch[x][i]);
  }
  ans[deep[x]] += size[x] - 1 - (size[root] - 1);
  for (int i = 0; i < 26; i++) {
    if (!ch[x][i]) continue;
    dsu(ch[x][i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d %c", &x, &y, &c);
    g[x].push_back(pair<int, int>(y, c - 'a'));
  }
  dfs(1, 0, 1);
  dsu(1);
  int p = 0;
  for (int i = 1; i <= n - 1; i++)
    if (ans[i] > ans[p]) p = i;
  printf("%d\n%d", n - ans[p], p);
  return 0;
}
