#include <bits/stdc++.h>
using namespace std;
const long long COEF = 29;
const long long COEF1 = 29;
const long long COEF2 = 29;
const long long MODULO1 = 1000000007;
const long long MODULO2 = 1000000009;
const int N = 300007;
long long COEF_INV1, COEF_INV2;
long long powMod(long long x, long long y, long long MODULO) {
  long long z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = z * x % MODULO;
    x = x * x % MODULO;
  }
  return z;
}
long long inv1(long long x) { return powMod(x, MODULO1 - 2, MODULO1); }
long long inv2(long long x) { return powMod(x, MODULO2 - 2, MODULO2); }
struct Set {
  set<pair<long long, long long>> values;
  long long coef1, coefInv1, delta1;
  long long coef2, coefInv2, delta2;
  Set() {
    coef1 = coefInv1 = 1;
    coef2 = coefInv2 = 1;
    delta1 = delta2 = 0;
  }
  void addBack(int c) {
    coef1 = coef1 * COEF % MODULO1;
    coefInv1 = coefInv1 * COEF_INV1 % MODULO1;
    delta1 = (delta1 * COEF1 + c) % MODULO1;
    coef2 = coef2 * COEF % MODULO2;
    coefInv2 = coefInv2 * COEF_INV2 % MODULO2;
    delta2 = (delta2 * COEF2 + c) % MODULO2;
  }
  void addInto(pair<long long, long long> value) {
    long long norm1 = (value.first - delta1) * coefInv1 % MODULO1;
    if (norm1 < 0) {
      norm1 += MODULO1;
    }
    long long norm2 = (value.second - delta2) * coefInv2 % MODULO2;
    if (norm2 < 0) {
      norm2 += MODULO2;
    }
    values.insert(make_pair(norm1, norm2));
  }
  bool contains(pair<long long, long long> value) {
    long long norm1 = (value.first - delta1) * coefInv1 % MODULO1;
    if (norm1 < 0) {
      norm1 += MODULO1;
    }
    long long norm2 = (value.second - delta2) * coefInv2 % MODULO2;
    if (norm2 < 0) {
      norm2 += MODULO2;
    }
    return values.find(make_pair(norm1, norm2)) != values.end();
  }
} nodes[N];
int root[N];
vector<pair<int, int>> edge[N];
int mergeSets(int u, int v) {
  if (nodes[u].values.size() < nodes[v].values.size()) {
    swap(u, v);
  }
  for (__typeof(nodes[v].values.begin()) it = nodes[v].values.begin();
       it != nodes[v].values.end(); it++) {
    long long norm1 = (it->first * nodes[v].coef1 + nodes[v].delta1) % MODULO1;
    long long norm2 = (it->second * nodes[v].coef2 + nodes[v].delta2) % MODULO2;
    nodes[u].addInto(make_pair(norm1, norm2));
  }
  return u;
}
int answers[N];
set<pair<long long, long long>> addition;
void dfs(int x, int fa, int level) {
  root[x] = x;
  nodes[x].values.insert(make_pair(0LL, 0LL));
  vector<pair<int, int>> children;
  for (__typeof(edge[x].begin()) it = edge[x].begin(); it != edge[x].end();
       it++) {
    if (it->first == fa) {
      continue;
    }
    children.push_back(make_pair(it->first, it->second));
    dfs(it->first, x, level + 1);
  }
  sort(children.begin(), children.end(),
       [&](pair<int, int> a, pair<int, int> b) {
         return nodes[root[a.first]].values.size() >
                nodes[root[b.first]].values.size();
       });
  if (children.size() > 0) {
    int step = 1;
    addition.clear();
    auto& firstChildSet = nodes[root[children[0].first]];
    for (int i = 1; i < children.size(); ++i) {
      int v = root[children[i].first];
      for (__typeof(nodes[v].values.begin()) it = nodes[v].values.begin();
           it != nodes[v].values.end(); it++) {
        long long norm1 =
            (it->first * nodes[v].coef1 + nodes[v].delta1) % MODULO1;
        long long norm2 =
            (it->second * nodes[v].coef2 + nodes[v].delta2) % MODULO2;
        if (addition.find(make_pair(norm1, norm2)) == addition.end() &&
            !firstChildSet.contains(make_pair(norm1, norm2))) {
          addition.insert(make_pair(norm1, norm2));
        } else {
          ++step;
        }
      }
    }
    answers[level] += step;
    for (auto child : children) {
      nodes[root[child.first]].addBack(child.second);
      root[x] = mergeSets(root[x], root[child.first]);
    }
  }
}
int main() {
  COEF_INV1 = inv1(COEF);
  COEF_INV2 = inv2(COEF);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    static char ch[10];
    scanf("%d%d%s", &u, &v, ch);
    --u;
    --v;
    edge[u].push_back(make_pair(v, ch[0] - 'a' + 1));
    edge[v].push_back(make_pair(u, ch[0] - 'a' + 1));
  }
  dfs(0, -1, 0);
  int answer = -1;
  int answerAt = -1;
  for (int i = 0; i < n + 1; i++) {
    if (answer == -1 || answers[i] > answer) {
      answer = answers[i];
      answerAt = i;
    }
  }
  cout << n - answer << endl << 1 + answerAt << endl;
  return 0;
}
