#include <bits/stdc++.h>
using namespace std;
const int N = 300004;
int vis[N][26];
int t[N][26];
int p[N][26];
int id;
int merge(int x, int y) {
  int res = 0;
  for (int i = 0; i < 26; ++i) {
    if (t[y][i] > 0) {
      if (vis[x][i] != id) {
        ++res;
        vis[x][i] = id;
        p[x][i] = t[y][i];
      }
      res += merge(p[x][i], t[y][i]);
    }
  }
  return res;
}
int intersect(int x, int y) {
  int res = 0;
  for (int i = 0; i < 26; ++i) {
    if (vis[x][i] == id && t[y][i] > 0) {
      res += intersect(p[x][i], t[y][i]) + 1;
    }
  }
  return res;
}
vector<int> e[N];
vector<char> w[N];
int best[N];
void dfs(int u, int p) {
  for (int i = 0; i < e[u].size(); ++i) {
    int v = e[u][i];
    if (v != p) {
      t[u][w[u][i] - 'a'] = v;
      dfs(v, u);
    }
  }
}
int solve(int u, int p, int h) {
  int sz = 1;
  int pivot = -1, psz = -1;
  for (int v : e[u]) {
    if (v != p) {
      int csz = solve(v, u, h + 1);
      if (csz > psz) {
        psz = csz;
        pivot = v;
      }
      sz += csz;
    }
  }
  if (pivot == -1) return sz;
  int newAdded = psz - 1;
  id++;
  for (int v : e[u])
    if (v != p && v != pivot) {
      newAdded += merge(0, v);
    }
  newAdded -= intersect(0, pivot);
  best[h] += sz - 1 - newAdded;
  return sz;
}
int main() {
  memset(t, 255, sizeof t);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x, y;
  char c;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> x >> y >> c;
    e[x].push_back(y);
    e[y].push_back(x);
    w[x].push_back(c);
    w[y].push_back(c);
  }
  dfs(1, 0);
  solve(1, 0, 1);
  int optChar = 0, res = 0;
  for (int i = 1; i < N; ++i) {
    if (best[i] > res) {
      optChar = i;
      res = best[i];
    }
  }
  cout << (n - res) << "\n" << optChar;
  return 0;
}
