#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, t = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') t = -1;
    c = getchar();
  }
  while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
  return s * t;
}
const int N = 3e5 + 5;
inline void Max(int &x, int v) {
  if (v > x) x = v;
}
int son[N << 1][26], ti[N << 1][26], now;
struct edge {
  int to, nxt, v;
} e[N];
int n, f[N], head[N], cnt = 0, tot, sz[N], w[N];
bool in[N];
inline void add(int x, int y, int v) {
  in[x] = 1;
  e[++cnt].to = y, e[cnt].v = v, e[cnt].nxt = head[x], head[x] = cnt;
}
inline void d1(int x) {
  sz[x] = 1, w[x] = 0;
  for (register int i = head[x]; i; i = e[i].nxt) {
    d1(e[i].to), sz[x] += sz[e[i].to];
    if (sz[e[i].to] > sz[w[x]]) w[x] = e[i].to;
  }
}
int ret;
inline void build(int x, int k) {
  for (register int i = head[x]; i; i = e[i].nxt)
    ti[k][e[i].v] = now, build(e[i].to, son[k][e[i].v] = ++tot);
}
inline void d2(int x, int k) {
  ret++;
  for (register int i = head[x]; i; i = e[i].nxt) {
    if (son[k][e[i].v] && (son[k][e[i].v] <= n || ti[k][e[i].v] == now))
      d2(e[i].to, son[k][e[i].v]);
    else
      ti[k][e[i].v] = now, build(e[i].to, son[k][e[i].v] = ++tot);
  }
}
inline void dfs(int x, int g) {
  if (!in[x]) return;
  for (register int i = head[x]; i; i = e[i].nxt) dfs(e[i].to, g + 1);
  tot = n, ret = 0, now = x;
  for (register int i = head[x]; i; i = e[i].nxt)
    if (e[i].to != w[x]) d2(e[i].to, w[x]);
  ret++;
  f[g] += ret;
}
int main() {
  n = read();
  int x, y;
  char c;
  for (register int i = 1; i <= n - 1; i++) {
    x = read(), y = read();
    c = getchar();
    while (c < 'a' && c > 'z') c = getchar();
    son[x][c - 'a'] = y, add(x, y, c - 'a');
  }
  d1(1), dfs(1, 1);
  int id = 1;
  for (register int i = 2; i <= n; i++)
    if (f[i] > f[id]) id = i;
  cout << n - f[id] << endl << id << endl;
  return 0;
}
