#include <bits/stdc++.h>
using namespace std;
const int mx = 3e5 + 10;
int n, m;
vector<int> vec[mx];
char ns[mx];
int dep[mx], sz[mx], a[mx], b[mx][26], cnt;
pair<int, int> tp[mx];
void dfs2(int u, int rt, int d) {
  for (int v : vec[u]) {
    if (b[rt][ns[v] - 'a'])
      dfs2(v, b[rt][ns[v] - 'a'], d), ++a[d];
    else {
      b[rt][ns[v] - 'a'] = v;
      tp[++cnt] = make_pair(rt, ns[v] - 'a');
    }
  }
}
void dfs(int u) {
  sz[u] = 1;
  int rt = 0;
  for (int v : vec[u]) {
    dep[v] = dep[u] + 1;
    dfs(v);
    sz[u] += sz[v];
    if (sz[rt] < sz[v]) {
      rt = v;
    }
  }
  cnt = 0;
  for (int v : vec[u]) {
    if (v != rt) {
      dfs2(v, rt, dep[v]);
    }
  }
  for (int i = 1; i <= cnt; ++i) {
    b[tp[i].first][tp[i].second] = 0;
  }
}
int main() {
  int u, v;
  char s[2];
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%s", &u, &v, s);
    vec[u].push_back(v);
    ns[v] = s[0];
    b[u][s[0] - 'a'] = v;
  }
  dep[1] = 0, sz[0] = -0x3f3f3f3f;
  dfs(1);
  for (int i = 1; i <= n; ++i) {
    ++a[dep[i]];
  }
  int ans = n, res = 0;
  for (int i = 1; i <= n && a[i]; ++i) {
    if (n - a[i] < ans) {
      ans = n - a[i], res = i;
    }
  }
  printf("%d\n%d\n", ans, res);
}
