#include <bits/stdc++.h>
using namespace std;
const int MAXN = 330000;
int ch[MAXN][26];
int siz[MAXN], son[MAXN];
vector<int> p[MAXN];
vector<pair<int, int>> t;
void dfs(int u, int d) {
  siz[u] = 1, son[u] = 0;
  p[d].push_back(u);
  for (int i = 0; i < 26; i++) {
    int v = ch[u][i];
    if (v) {
      dfs(v, d + 1);
      siz[u] += siz[v];
      if (siz[v] > siz[son[u]]) son[u] = v;
    }
  }
}
void merge(int u, int v, int& c) {
  for (int i = 0; i < 26; i++)
    if (ch[u][i]) {
      if (!ch[v][i]) {
        c += siz[ch[u][i]];
        ch[v][i] = ch[u][i];
        t.push_back(make_pair(v, i));
      } else
        merge(ch[u][i], ch[v][i], c);
    }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    char c[2];
    scanf("%d%d%s", &u, &v, c);
    ch[u][c[0] - 'a'] = v;
  }
  dfs(1, 1);
  siz[0] = 1;
  int mn = n, id;
  for (int k = 1; !p[k].empty(); k++) {
    int cnt = n;
    for (int u : p[k]) {
      t.clear();
      cnt -= siz[u] - siz[son[u]];
      for (int i = 0; i < 26; i++) {
        int v = ch[u][i];
        if (v && v != son[u]) merge(v, son[u], cnt);
      }
      for (auto x : t) ch[x.first][x.second] = 0;
    }
    if (cnt < mn) mn = cnt, id = k;
  }
  printf("%d\n%d\n", mn, id);
  return 0;
}
