#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5 + 100;
vector<pair<int, int> > e[maxN];
int g[maxN][26];
int d[maxN];
int depth[maxN];
int sz[maxN];
int depthsum[maxN];
int dpsum[maxN];
struct kek {
  int t;
  int x, val;
  int y;
  kek() {}
  kek(int t, int x, int y, int val) : t(t), x(x), y(y), val(val){};
};
vector<kek> act;
int cnt = 0;
int calc_sz(int v) {
  int r = 1;
  for (auto u : e[v]) {
    r += calc_sz(u.first);
  }
  sz[v] = r;
  return r;
}
int _merge(int x, int y) {
  for (auto u : e[y]) {
    if (g[x][u.second] != -1) {
      act.push_back(kek(0, x, 0, sz[x]));
      cnt++;
      sz[x] -= sz[g[x][u.second]];
      sz[x] += _merge(g[x][u.second], u.first);
    } else {
      act.push_back(kek(1, x, u.second, -1));
      cnt++;
      g[x][u.second] = u.first;
      act.push_back(kek(2, x, 0, 0));
      cnt++;
      e[x].push_back(make_pair(u.first, u.second));
      act.push_back(kek(0, x, 0, sz[x]));
      cnt++;
      sz[x] += sz[u.first];
    }
  }
  return sz[x];
}
int md = 0;
void dfs(int v, int cd = 0) {
  md = max(md, cd);
  depth[v] = cd;
  depthsum[cd]++;
  vector<vector<int> > to_merge(26, vector<int>());
  for (auto u : e[v]) {
    for (auto x : e[u.first]) {
      to_merge[x.second].push_back(x.first);
    }
  }
  for (int i = 0; i < 26; i++) {
    if (to_merge[i].size() == 0) continue;
    int curr = to_merge[i][0];
    for (int j = 1; j < to_merge[i].size(); j++) {
      if (sz[curr] < sz[to_merge[i][j]]) {
        swap(curr, to_merge[i][j]);
      }
      _merge(curr, to_merge[i][j]);
    }
    d[v] += sz[curr];
    while (cnt > 0) {
      if (act.back().t == 0) {
        sz[act.back().x] = act.back().val;
      }
      if (act.back().t == 1) {
        g[act.back().x][act.back().y] = act.back().val;
      }
      if (act.back().t == 2) {
        e[act.back().x].pop_back();
      }
      cnt--;
      act.pop_back();
    }
  }
  dpsum[cd] += d[v];
  for (auto u : e[v]) {
    dfs(u.first, cd + 1);
  }
}
int main() {
  for (int i = 0; i < maxN; i++) {
    for (int j = 0; j < 26; j++) {
      g[i][j] = -1;
    }
  }
  int n;
  scanf("%d\n", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    char x;
    scanf("%d %d %c\n", &u, &v, &x);
    x -= 'a';
    u--;
    v--;
    e[u].push_back(make_pair(v, x));
    g[u][x] = v;
  }
  calc_sz(0);
  dfs(0);
  int res = 1e9;
  int p = 0;
  int currup = 0;
  for (int i = 0; i < md; i++) {
    currup += depthsum[i];
    if (currup + dpsum[i] < res) {
      res = currup + dpsum[i];
      p = i;
    }
  }
  cout << res << "\n" << p + 1;
  return 0;
}
