#include <bits/stdc++.h>
using namespace std;
const int maxn = 600000 + 10;
int n, ch[maxn][26], ans[maxn], dep[maxn], tot, sz[maxn];
struct node {
  int to, v;
};
vector<node> g[maxn];
int merge(int a, int b) {
  if (!a || !b) return a + b;
  int x = ++tot;
  sz[x] = 1;
  for (int i = 0; i < 26; i++) {
    ch[x][i] = merge(ch[a][i], ch[b][i]);
    sz[x] += sz[ch[x][i]];
  }
  return x;
}
void dfs(int p, int fa) {
  sz[p] = 1;
  for (int i = 0; i < g[p].size(); i++) {
    int u = g[p][i].to;
    if (u == fa) continue;
    ch[p][g[p][i].v] = u;
    dep[u] = dep[p] + 1;
    dfs(u, p);
    sz[p] += sz[u];
  }
  ans[dep[p] + 1] += sz[p];
  tot = n;
  int h = 0;
  for (int i = 0; i < 26; i++) h = merge(h, ch[p][i]);
  ans[dep[p] + 1] -= max(sz[h], 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    char op;
    cin >> x >> y >> op;
    g[x].push_back((node){y, op - 'a'});
    g[y].push_back((node){x, op - 'a'});
  }
  dfs(1, -1);
  int ansj = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i] > ans[ansj]) ansj = i;
  printf("%d\n%d\n", n - ans[ansj], ansj);
  return 0;
}
