#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > g[300010];
int mas[26][300010];
int d[300010];
char used[300010];
vector<int> h[300010];
int depth = 0;
map<int, int> cnt;
map<int, int> cnt2;
void dfs(int v) {
  used[v] = true;
  depth++;
  h[depth].push_back(v);
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (!used[to]) {
      dfs(to);
      d[v] += d[to];
    }
  }
  d[v] += 1;
  depth--;
}
void Merge(int t1, int t2) {
  for (int i = 0; i < g[t2].size(); i++) {
    int edge = g[t2][i].second - 'a';
    if (mas[edge][t1] != 0) {
      d[t1] -= d[mas[edge][t1]];
      cnt2[t1] -= d[mas[edge][t1]];
      Merge(mas[edge][t1], g[t2][i].first);
      d[t1] += d[mas[edge][t1]];
      cnt2[t1] += d[mas[edge][t1]];
    } else {
      g[t1].push_back(g[t2][i]);
      mas[edge][t1] = g[t2][i].first;
      d[t1] += d[g[t2][i].first];
      cnt[t1]++;
      cnt2[t1] += d[g[t2][i].first];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    char c;
    cin >> u >> v >> c;
    g[u - 1].push_back(make_pair(v - 1, c));
    mas[c - 'a'][u - 1] = v - 1;
  }
  dfs(0);
  int ans = 1000000000, p = 0;
  for (int i = 1; i <= n; i++) {
    if ((int)h[i].size() == 0) break;
    int diff = 0;
    for (int j = 0; j < (int)h[i].size(); j++) {
      int mxSz = 0, mxNum = 0;
      int u = h[i][j];
      if (g[u].size() == 0) continue;
      for (int k = 0; k < (int)g[u].size(); k++) {
        int v = g[u][k].first;
        if (d[v] > mxSz) {
          mxSz = d[v];
          mxNum = k;
        }
      }
      for (int k = 0; k < (int)g[u].size(); k++) {
        if (k == mxNum) continue;
        Merge(g[u][mxNum].first, g[u][k].first);
      }
      diff += d[u] - d[g[u][mxNum].first];
      for (auto u : cnt) {
        for (int k = 0; k < u.second; k++) {
          pair<int, int> cur = g[u.first].back();
          g[u.first].pop_back();
          int edge = cur.second - 'a';
          mas[edge][u.first] = 0;
        }
      }
      for (auto u : cnt2) {
        d[u.first] -= u.second;
      }
      cnt.clear();
      cnt2.clear();
    }
    if (d[0] - diff < ans) {
      ans = d[0] - diff;
      p = i;
    }
  }
  cout << ans << endl << p << endl;
  return 0;
}
