#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9 + 7;
vector<string> v;
int ans = 0;
int to[28][300300];
int id[300300], cnt[300300];
int sz = 1;
int is_terminal[300300];
void read() {
  string cur = "";
  while (true) {
    char c = getchar();
    if ((int)c <= 0) break;
    if (c >= 'a' && c <= 'z') {
      cur += c;
    } else {
      ans++;
      if (cur.size() > 0) v.push_back(cur);
      cur = "";
    }
  }
  if (cur.size() > 0) v.push_back(cur);
}
bool can_tab(string &s) {
  int v = 0;
  for (int i = 0; i < (int((s).size())); i++) {
    int c = s[i] - 'a';
    if (to[c][v] == -1) return false;
    v = to[c][v];
    if (is_terminal[v] && cnt[v] == 1) return true;
  }
  return false;
}
int min_tab(string &s) {
  int v = 0;
  for (int i = 0; i < (int((s).size())); i++) {
    int c = s[i] - 'a';
    if (to[c][v] == -1) assert(false);
    v = to[c][v];
    if (cnt[v] == 1) return i;
  }
  assert(false);
}
int max_tab(string &s) {
  int v = 0;
  int best = -1;
  for (int i = 0; i < (int((s).size())); i++) {
    int c = s[i] - 'a';
    if (to[c][v] == -1) break;
    v = to[c][v];
    if (cnt[v] == 1) best = i;
  }
  if (best == -1) assert(false);
  return best;
}
int get_id(string &s) {
  int v = 0;
  int best = -1;
  for (int i = 0; i < (int((s).size())); i++) {
    int c = s[i] - 'a';
    if (to[c][v] == -1) break;
    v = to[c][v];
    if (cnt[v] == 1) best = i;
  }
  if (best == -1) assert(false);
  return id[v];
}
void add(string &s, int ind) {
  int v = 0;
  cnt[v]++;
  id[v] = ind;
  for (int i = 0; i < (int((s).size())); i++) {
    int c = s[i] - 'a';
    if (to[c][v] == -1) to[c][v] = sz++;
    v = to[c][v];
    cnt[v]++;
    id[v] = ind;
  }
  if (is_terminal[v]) {
    v = 0;
    cnt[v]--;
    for (int i = 0; i < (int((s).size())); i++) {
      int c = s[i] - 'a';
      v = to[c][v];
      cnt[v]--;
    }
  }
  is_terminal[v] = 1;
}
void process(int ind) {
  string &s = v[ind];
  if (!can_tab(s)) {
    ans += s.size();
    add(s, ind);
  } else {
    int cur = s.size();
    int mn = min_tab(s);
    int mx = max_tab(s);
    int len = s.size();
    int l = v[get_id(s)].size();
    cur = min(cur, mn + 1 + 1 + (len - mx - 1));
    ans += cur;
    add(s, ind);
  }
}
int main() {
  memset(to, -1, sizeof to);
  read();
  for (int i = 0; i < v.size(); i++) process(i);
  cout << ans << endl;
  return 0;
}
