#include <bits/stdc++.h>
using namespace std;
int n;
int tree[300003][26];
int levels[300003];
int merge(vector<int> nds) {
  int ans = 0;
  for (int i = 0; i < 26; i++) {
    vector<int> duplicated;
    for (int j = 0; j < (int)nds.size(); j++) {
      if (tree[nds[j]][i]) duplicated.push_back(tree[nds[j]][i]);
    }
    if (duplicated.size() > 1) {
      ans += duplicated.size() - 1;
      ans += merge(duplicated);
    }
  }
  return ans;
}
void dfs(int nd, int level) {
  vector<int> nds;
  for (int i = 0; i < 26; i++) {
    if (!tree[nd][i]) continue;
    nds.push_back(tree[nd][i]);
  }
  if (nds.size() > 1) levels[level] += merge(nds);
  levels[level] += nds.size();
  for (int i = 0; i < (int)nds.size(); i++) dfs(nds[i], level + 1);
}
int main() {
  memset(tree, 0, sizeof(tree));
  memset(levels, 0, sizeof(levels));
  scanf("%d", &n);
  char ch;
  int a;
  int b;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d %c", &a, &b, &ch);
    a--;
    b--;
    tree[a][ch - 'a'] = b;
  }
  dfs(0, 0);
  int maxl = 0;
  int p;
  for (int i = 0; i < n; i++) {
    if (levels[i] > maxl) {
      maxl = levels[i];
      p = i + 1;
    }
  }
  printf("%d\n%d", n - maxl, p);
  return 0;
}
