#include <bits/stdc++.h>
using namespace std;
int ans[1000000];
int gr[1000000][26];
int merge(vector<int> a) {
  int res = a.size() - 1, i, j;
  for (j = 0; j < 26; j++) {
    vector<int> s;
    for (i = 0; i < a.size(); i++) {
      if (gr[a[i]][j]) s.push_back(gr[a[i]][j]);
    }
    if (s.size() <= 1) continue;
    res = res + merge(s);
  }
  return res;
}
void dfs(int e, int dep) {
  int i;
  vector<int> s;
  s.clear();
  for (i = 0; i < 26; i++)
    if (gr[e][i]) s.push_back(gr[e][i]);
  ans[dep] += merge(s) + 1;
  for (i = 0; i < 26; i++)
    if (gr[e][i]) dfs(gr[e][i], dep + 1);
}
using namespace std;
int main() {
  int n, i;
  cin >> n;
  for (i = 0; i < n - 1; i++) {
    int u, v;
    char ch;
    cin >> u >> v >> ch;
    gr[u][ch - 'a'] = v;
  }
  dfs(1, 1);
  int max = 0, val = 0;
  for (i = 1; i <= n; i++)
    if (ans[i] > max) {
      max = ans[i];
      val = i;
    }
  cout << (n - max) << endl << val << endl;
  return 0;
}
