#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, int> > g[300100];
int dep[300100];
vector<int> op[30];
int ans1;
void dfs(int x, int r) {
  dep[x] = r;
  for (int i = 0; i < g[x].size(); i++) {
    int ver = g[x][i].first;
    if (dep[ver] == 0) dfs(ver, r + 1);
  }
  return;
}
void dfs1(vector<int> p[], int r) {
  vector<int> opp[30];
  for (int i = 0; i < 26; i++) {
    if (p[i].size()) {
      for (int j = 0; j < 26; j++) {
        opp[j].clear();
      }
      ans1++;
      if (p[i].size() > 1) {
        for (int j = 0; j < p[i].size(); j++) {
          int ver = p[i][j];
          for (int z = 0; z < g[ver].size(); z++) {
            int ver1 = g[ver][z].first;
            if (dep[ver1] == r + 1) {
              ans1--;
              opp[g[ver][z].second].push_back(ver1);
            }
          }
        }
      }
      dfs1(opp, r + 1);
    }
  }
}
vector<int> v[300100];
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v1;
    char x;
    scanf("%d %d %c", &u, &v1, &x);
    int x1 = x - 'a';
    g[u].push_back({v1, x1});
    g[v1].push_back({u, x1});
  }
  dfs(1, 1);
  for (int i = 1; i <= n; i++) {
    v[dep[i]].push_back(i);
  }
  int ans = n;
  int p = 0;
  for (int i = 1;; i++) {
    if (v[i].size() == 0) break;
    ans1 = n;
    for (int j = 0; j < v[i].size(); j++) {
      int ver = v[i][j];
      for (int z = 0; z < 26; z++) {
        op[z].clear();
      }
      for (int z = 0; z < g[ver].size(); z++) {
        int ver1 = g[ver][z].first;
        if (dep[ver1] == i + 1) {
          ans1--;
          for (int z1 = 0; z1 < g[ver1].size(); z1++) {
            int ver2 = g[ver1][z1].first;
            if (dep[ver2] == i + 2) {
              ans1--;
              op[g[ver1][z1].second].push_back(ver2);
            }
          }
        }
      }
      dfs1(op, i + 2);
    }
    if (ans1 < ans) {
      ans = ans1;
      p = i;
    }
  }
  printf("%d\n%d", ans, p);
  return 0;
}
