#include <bits/stdc++.h>
using namespace std;
const int N = 3 * (int)1e5 + 10;
int n, to[N][28], Count[N], ans, u, v;
char ch;
struct node {
  int val;
  node *con[28];
  node() {
    val = 0;
    for (int i = 0; i < 26; ++i) con[i] = NULL;
  }
};
vector<pair<node *, int> > vt;
void cal(node *cur, node *p) {
  for (int i = 0; i < 26; ++i)
    if (p->con[i]) {
      if (cur->con[i] == NULL) {
        cur->con[i] = p->con[i];
        vt.push_back(pair<node *, int>(cur, i));
      } else {
        ans++;
        cal(cur->con[i], p->con[i]);
      }
    }
}
void dfs(node *p, int depth) {
  node *root = new node;
  ans = 0;
  for (int i = 0; i < 26; ++i)
    if (p->con[i]) {
      ans++;
      cal(root, p->con[i]);
    }
  for (int i = 0; i < vt.size(); ++i) vt[i].first->con[vt[i].second] = NULL;
  vt.clear();
  Count[depth] += ans;
  for (int i = 0; i < 26; ++i)
    if (p->con[i]) dfs(p->con[i], depth + 1);
}
void dfsRoot(node *root, int u) {
  root->val = u;
  for (int i = 0; i < 26; ++i)
    if (to[u][i]) {
      if (root->con[i] == NULL) root->con[i] = new node;
      dfsRoot(root->con[i], to[u][i]);
    }
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v >> ch;
    to[u][ch - 'a'] = v;
  }
  node *root = new node;
  dfsRoot(root, 1);
  dfs(root, 1);
  int MIN = 1;
  for (int i = 1; i <= n; ++i)
    if (Count[i] > Count[MIN]) MIN = i;
  cout << n - Count[MIN] << '\n';
  cout << MIN;
  return 0;
}
