#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > f(const vector<string> &, int, int, int);
set<pair<int, int> > split(const vector<string> &v, int l, int r, int idx) {
  if (l == r) return set<pair<int, int> >();
  set<pair<int, int> > ret;
  for (int i = l + 1; i < r; ++i) {
    if (v[i][idx] != v[i - 1][idx]) {
      set<pair<int, int> > s = f(v, l, i, idx + 1);
      ret.insert(s.begin(), s.end());
      l = i;
    }
  }
  set<pair<int, int> > s = f(v, l, r, idx + 1);
  ret.insert(s.begin(), s.end());
  return ret;
}
set<pair<int, int> > f(const vector<string> &v, int l, int r, int idx) {
  if (l == r) return set<pair<int, int> >();
  bool f = 0;
  if (v[l].size() == idx) {
    f = 1;
    ++l;
  }
  set<pair<int, int> > s = split(v, l, r, idx);
  s.insert({idx, (rand() << 16) + rand()});
  if (!f) {
    s.erase(--s.end());
  }
  return s;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  srand(123456789);
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  set<pair<int, int> > s = split(v, 0, v.size(), 0);
  long long ans = 0;
  for (auto p : s) {
    ans += p.first;
  }
  cout << ans << endl;
}
