#include <bits/stdc++.h>
int n;
int edges[300030], next[600060], to[600060], cost[600060];
int size[300030], son[300030];
int children[600060][26], tail;
int result[300030];
int queue[600060], in;
void edge_add(int u, int v, int c) {
  static int count = 1;
  to[count] = v;
  cost[count] = c;
  next[count] = edges[u];
  edges[u] = count++;
}
void dfs(int x, int y) {
  int e;
  size[x] = 1;
  for (e = edges[x]; e; e = next[e]) {
    if (to[e] == y) continue;
    dfs(to[e], x);
    children[x][cost[e]] = to[e];
    size[x] += size[to[e]];
    if (!son[x] || size[to[e]] > size[son[x]]) son[x] = to[e];
  }
}
void work(int x, int y, int z, int w) {
  int i;
  int e;
  for (e = edges[x]; e; e = next[e]) {
    if (to[e] == w) continue;
    if (children[y][cost[e]])
      ++result[z];
    else
      queue[in++] = y, queue[in++] = cost[e], children[y][cost[e]] = tail++;
    work(to[e], children[y][cost[e]], z, x);
  }
}
void solve(int x, int y, int z) {
  int e;
  int i;
  if (!son[x]) return;
  for (e = edges[x]; e; e = next[e]) {
    if (to[e] == y) continue;
    solve(to[e], x, z + 1);
  }
  ++result[z];
  tail = n + 1;
  in = 0;
  for (e = edges[x]; e; e = next[e]) {
    if (to[e] == y) continue;
    if (to[e] == son[x]) continue;
    work(to[e], son[x], z, x);
    ++result[z];
  }
  memset(children + n + 1, 0, sizeof(children[0]) * (tail - n - 1));
  for (i = 0; i < in; i += 2) children[queue[i]][queue[i + 1]] = 0;
}
int main(void) {
  int i;
  int u, v;
  char c;
  scanf("%d", &n);
  for (i = 0; i < n - 1; ++i)
    scanf("%d %d %c", &u, &v, &c), edge_add(u, v, c - 'a'),
        edge_add(v, u, c - 'a');
  dfs(1, 0);
  solve(1, 0, 0);
  u = v = -1;
  for (i = n - 1; i >= 0; --i)
    if (result[i] >= u) u = result[i], v = i;
  printf("%d\n%d\n", n - result[v], v + 1);
  return 0;
}
