#include <bits/stdc++.h>
using namespace std;
const int maxn = 300 * 1000 + 10, maxc = 26;
int n, ans[maxn], mni, u, v, z[maxn], ch[2 * maxn][maxc], h[maxn], cnt;
vector<pair<int, int>> vec[maxn], tmp;
char c;
bool big[maxn];
void pp(int x) {
  z[x] = 1;
  for (auto w : vec[x]) {
    h[w.first] = h[x] + 1;
    pp(w.first);
    z[x] += z[w.first];
  }
}
void build(int x, int y) {
  for (auto w : vec[x]) {
    if (ch[y][w.second] == 0) {
      tmp.push_back({y, w.second});
      ch[y][w.second] = n + cnt - z[u];
      cnt++;
    }
    build(w.first, ch[y][w.second]);
  }
}
void dfs(int x) {
  int mxz = -1, mxi = -1;
  for (auto w : vec[x]) {
    if (z[w.first] > mxz) {
      mxz = z[w.first];
      mxi = w.first;
    }
  }
  for (auto w : vec[x]) {
    if (w.first != mxi) dfs(w.first);
  }
  if (mxi != -1) {
    big[mxi] = 1;
    dfs(mxi);
  }
  for (auto w : vec[x]) {
    if (w.first != mxi) build(w.first, mxi);
  }
  if (mxi != -1) ans[h[x]] -= z[x] - cnt;
  for (auto w : tmp) ch[w.first][w.second] = 0;
  tmp.clear();
  if (big[x]) {
    cnt = z[x];
    u = x;
  }
}
int main() {
  ios::sync_with_stdio(0);
  scanf("%d", &n);
  ans[n] = maxn;
  mni = n + 1;
  for (int i = 0; i < n - 1; i++) {
    ans[i] = n;
    scanf("%d %d %c", &u, &v, &c);
    u--;
    v--;
    vec[u].push_back({v, c - 'a'});
    ch[u][c - 'a'] = v;
  }
  pp(0);
  dfs(0);
  for (int i = 0; i < n - 1; i++) {
    if (ans[i] < ans[mni - 1]) mni = i + 1;
  }
  printf("%d\n%d", ans[mni - 1], mni);
  return 0;
}
