#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5;
const long long M = 3e7;
const long long mod = 924844033;
const long long inf = 1e18;
inline long long read() {
  long long s = 0;
  register bool neg = 0;
  register char c = getchar();
  for (; c < '0' || c > '9'; c = getchar()) neg |= (c == '-');
  for (; c >= '0' && c <= '9'; s = s * 10 + (c ^ 48), c = getchar())
    ;
  s = (neg ? -s : s);
  return s;
}
long long a, siz[N + 10], mxs[N + 10], dis[N + 10], son[N + 10][26], sum,
    ans[N + 10], mx;
vector<pair<long long, long long> > st[N + 10];
inline void dfs(long long n) {
  siz[n] = 1;
  for (long long i = 0; i < st[n].size(); i++) {
    long long v = st[n][i].first;
    dfs(v);
    siz[n] += siz[v];
    if (siz[v] > siz[mxs[n]]) mxs[n] = v;
  }
}
inline void calc(long long n, long long m) {
  ++sum;
  for (long long i = 0; i < st[m].size(); i++) {
    long long v = st[m][i].first;
    if (!son[n][st[m][i].second]) {
      son[n][st[m][i].second] = v;
      continue;
    }
    calc(son[n][st[m][i].second], v);
  }
}
inline void clear(long long n, long long m) {
  for (long long i = (long long)st[m].size() - 1; i >= 0; i--) {
    long long v = st[m][i].first;
    if (son[n][st[m][i].second] == v) {
      son[n][st[m][i].second] = 0;
      continue;
    }
    clear(son[n][st[m][i].second], v);
  }
}
inline void Dfs(long long n) {
  if (!mxs[n]) return;
  for (long long i = 0; i < st[n].size(); i++) {
    long long v = st[n][i].first;
    Dfs(v);
  }
  for (long long i = 0; i < st[n].size(); i++) {
    long long v = st[n][i].first;
    if (v == mxs[n]) continue;
    calc(mxs[n], v);
  }
  dis[n] = sum + 1;
  for (long long i = (long long)st[n].size() - 1; i >= 0; i--) {
    long long v = st[n][i].first;
    if (v == mxs[n]) continue;
    clear(mxs[n], v);
  }
  sum = 0;
}
inline void dfsans(long long n, long long dep) {
  ans[dep] += dis[n];
  mx = max(mx, dep);
  for (long long i = 0; i < st[n].size(); i++) {
    long long v = st[n][i].first;
    dfsans(v, dep + 1);
  }
}
signed main() {
  a = read();
  long long x, y;
  char ch;
  for (long long i = 1; i < a; i++) {
    scanf("%lld %lld %c", &x, &y, &ch);
    st[x].push_back(make_pair(y, ch - 'a'));
    son[x][ch - 'a'] = y;
  }
  dfs(1);
  Dfs(1);
  dfsans(1, 1);
  long long Ans = 1;
  for (long long i = 2; i <= mx; i++)
    if (ans[Ans] < ans[i]) Ans = i;
  printf("%lld\n%lld", a - ans[Ans], Ans);
  return 0;
}
