#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v);
template <typename A, typename B>
ostream& operator<<(ostream& cout, pair<A, B> const& p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A>
ostream& operator<<(ostream& cout, vector<A> const& v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
istream& operator>>(istream& cin, pair<A, B>& p) {
  cin >> p.first;
  return cin >> p.second;
}
mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
void usaco(string filename) {
  freopen((filename + ".in").c_str(), "r", stdin);
  freopen((filename + ".out").c_str(), "w", stdout);
}
const long double pi = 3.14159265358979323846;
long long n, m, q, k, l, r, x, y, z;
const long long template_array_size = 1e6 + 16318;
long long a[template_array_size];
long long b[template_array_size];
long long c[template_array_size];
string second, t;
long long ans = 0;
struct node {
  node* nxt[26];
  long long cnt;
  node() {
    cnt = 0;
    for (long long i = 0; i < 26; i++) nxt[i] = nullptr;
  }
  node* next(char c) {
    if (!nxt[c - 'a']) nxt[c - 'a'] = new node;
    return nxt[c - 'a'];
  }
};
vector<pair<long long, char>> edges[300005];
long long val[300005];
node* tr[300005];
long long sz[300005];
void add(long long v, long long p, node* targ, long long t, long long d) {
  targ->cnt += d;
  for (pair<long long, char> x : edges[v])
    if (x.first != p) {
      node* nv = targ->next(x.second);
      if (nv->cnt != 0 && d == 1) ++val[t];
      add(x.first, v, nv, t, d);
    }
}
void dfs(long long v, long long p, long long d) {
  sz[v] = 1;
  long long bigc = -1, bigv = -1;
  for (pair<long long, char> x : edges[v])
    if (x.first != p) {
      dfs(x.first, v, d + 1);
      sz[v] += sz[x.first];
      if (sz[x.first] > bigv) {
        bigv = sz[x.first];
        bigc = x.first;
      }
    }
  val[d] += edges[v].size() - (p != -1);
  tr[v] = new node;
  tr[v]->cnt = 1;
  for (pair<long long, char> x : edges[v])
    if (x.first != p) {
      if (x.first != bigc) {
        add(x.first, v, tr[bigc], d, 1);
      }
    }
  for (pair<long long, char> x : edges[v])
    if (x.first != p) {
      if (x.first != bigc) {
        add(x.first, v, tr[bigc], d, -1);
      }
    }
  for (pair<long long, char> x : edges[v])
    if (x.first != p) {
      tr[v]->nxt[x.second - 'a'] = tr[x.first];
    }
}
void solve(int tc = 0) {
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    char c;
    cin >> x >> y >> c;
    --x;
    --y;
    edges[x].push_back({y, c});
    edges[y].push_back({x, c});
  }
  dfs(0, -1, 0);
  long long ans = -1, sv = -1;
  for (long long i = 0; i < n; i++) {
    if (val[i] > ans) {
      ans = val[i];
      sv = i + 1;
    }
  }
  cout << n - ans << '\n' << sv << '\n';
}
int main() {
  { ios_base::sync_with_stdio(false); }
  { cin.tie(NULL); }
  cout << setprecision(15) << fixed;
  int tc = 1;
  for (int t = 0; t < tc; t++) solve(t);
}
