#include <bits/stdc++.h>
using namespace std;
const int DIM = 300005;
int szt[DIM], fth[DIM], sum[DIM];
vector<int> lst[DIM];
map<char, int> nxt[DIM], nxt2[DIM];
vector<pair<int, char>> edg[DIM];
inline bool cmp(int x, int y) { return szt[x] > szt[y]; }
void dfs(int x, int f, int l) {
  lst[l].push_back(x);
  szt[x] = 1;
  fth[x] = f;
  for (auto pr : edg[x]) {
    int y = pr.first;
    if (y != f) {
      nxt[x][pr.second] = y;
      dfs(y, x, l + 1);
      szt[x] += szt[y];
    }
  }
}
void dfs2(int x, int f, int c, int &m) {
  for (auto pr : edg[x]) {
    int y = pr.first;
    if (y == f) continue;
    if (nxt2[c].find(pr.second) == nxt2[c].end()) {
      nxt2[++m].clear();
      nxt2[c][pr.second] = m;
    }
    dfs2(y, x, nxt2[c][pr.second], m);
  }
}
void dfs3(int x, int v, int &pans) {
  --pans;
  for (auto pr : nxt2[x]) {
    char ch = pr.first;
    int y = pr.second;
    if (nxt[v].find(ch) != nxt[v].end()) dfs3(y, nxt[v][ch], pans);
  }
}
int main(void) {
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int x, y;
    char ch;
    cin >> x >> y >> ch;
    edg[x].push_back(make_pair(y, ch));
    edg[y].push_back(make_pair(x, ch));
  }
  dfs(1, 0, 1);
  int mn = n + 1, ps = -1;
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + lst[i].size();
    int pans = sum[i - 1];
    for (int x : lst[i]) {
      vector<int> aux;
      for (auto pr : edg[x]) {
        int y = pr.first;
        if (y != fth[x]) aux.push_back(y);
      }
      if (aux.empty()) {
        ++pans;
        continue;
      }
      sort(aux.begin(), aux.end(), cmp);
      int m = 1;
      nxt2[m].clear();
      for (int y : aux) {
        if (y == aux.front()) continue;
        dfs2(y, x, 1, m);
      }
      pans += m + szt[aux[0]];
      dfs3(1, aux[0], pans);
    }
    if (pans < mn) {
      mn = pans;
      ps = i;
    }
  }
  cout << mn << endl << ps << endl;
  return 0;
}
