#include <bits/stdc++.h>
using namespace std;
const int maxN = 300010, Alph_size = 26;
vector<int> G[maxN];
int trie[maxN][Alph_size], size[maxN];
int sack[maxN][Alph_size], vis[maxN][Alph_size], w[maxN][Alph_size];
int sack_size = 1, sack_root = 1, vis_ctr = 1;
int res[maxN];
void add_edge(int v, int i, int u) {
  if (vis[v][i] == vis_ctr)
    sack[v][i] == u ? w[v][i]++ : w[v][i] = 1;
  else {
    vis[v][i] = vis_ctr;
    w[v][i] = 1;
  }
  sack[v][i] = u;
}
void rem_edge(int v, int i) {
  w[v][i]--;
  if (w[v][i] == 0) {
    sack_size--;
    vis[v][i]--;
  }
}
int get_size(int v) {
  size[v] = 1;
  for (int i = 0; i < G[v].size(); i++) size[v] += get_size(G[v][i]);
  return size[v];
}
void connect(int v, int vSack) {
  for (int i = 0; i < Alph_size; i++) {
    int u = trie[v][i];
    if (u == 0) continue;
    add_edge(vSack, i, vis[vSack][i] != vis_ctr ? ++sack_size : sack[vSack][i]);
    connect(u, sack[vSack][i]);
  }
}
void disconnect(int v, int vSack) {
  for (int i = Alph_size - 1; i >= 0; i--) {
    int u = trie[v][i];
    if (u == 0) continue;
    disconnect(u, sack[vSack][i]);
    rem_edge(vSack, i);
  }
}
void dfs(int v, int depth, bool clear) {
  if (G[v].empty()) return;
  int my_son = G[v][0];
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (size[my_son] < size[u]) my_son = u;
  }
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == my_son) continue;
    dfs(u, depth + 1, true);
  }
  dfs(my_son, depth + 1, false);
  for (int i = 0; i < G[v].size(); i++) {
    int u = G[v][i];
    if (u == my_son) continue;
    connect(u, sack_root);
  }
  res[depth + 1] += sack_size - size[v];
  if (clear) {
    vis_ctr++;
    sack_root = sack_size = 1;
    return;
  }
  for (int i = G[v].size() - 1; i >= 0; i--) {
    int u = G[v][i];
    if (u == my_son) continue;
    disconnect(u, sack_root);
  }
  for (int i = 0; i < Alph_size; i++) {
    int u = trie[v][i];
    if (u != my_son) continue;
    add_edge(++sack_size, i, sack_root);
    sack_root = sack_size;
    break;
  }
  for (int i = 0; i < Alph_size; i++) {
    int u = trie[v][i];
    if (u == 0 or u == my_son) continue;
    add_edge(sack_root, i, ++sack_size);
    connect(u, sack_size);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    char c[5];
    scanf("%d%d", &a, &b);
    scanf("%s", c);
    G[a].push_back(b);
    trie[a][c[0] - 'a'] = b;
  }
  fill(res, res + n + 1, n);
  get_size(1);
  dfs(1, 0, true);
  int result = res[1], d = 1;
  for (int i = 1; i <= n; i++)
    if (res[i] < result) result = res[i], d = i;
  printf("%d\n%d\n", result, d);
  return 0;
}
