#include <bits/stdc++.h>
using namespace std;
vector<int> to[300020];
int all[300020];
int tot[300020];
vector<char> go[300020];
int T, ans, a, b;
string q;
void add(int now, int pos) {
  if (tot[now]) {
    if (a > 0) ans++;
    a = 0;
  }
  if (pos == q.size()) {
    tot[now]++;
    if (tot[now] == 1) b = 1;
    all[now] += b;
    ans += a;
    return;
  }
  if (all[now] == 1 && go[now].size() == 1 && now != 1) {
    if (go[now][0] == q[pos]) {
      a++;
      add(to[now][0], pos + 1);
      all[now] += b;
      return;
    }
  }
  ans++;
  for (int i = 0; i < go[now].size(); i++) {
    if (go[now][i] == q[pos]) {
      add(to[now][i], pos + 1);
      all[now] += b;
      return;
    }
  }
  go[now].push_back(q[pos]);
  to[now].push_back(++T);
  add(T, pos + 1);
  all[now] += b;
}
int i, j;
string s;
int main() {
  T = 1;
  while (getline(cin, s)) {
    for (i = 0; i < s.size(); i++) {
      if (!(s[i] >= 'a' && s[i] <= 'z')) {
        ans++;
        continue;
      }
      q = "";
      for (j = i; j < s.size() && (s[j] >= 'a' && s[j] <= 'z'); j++) q += s[j];
      a = b = 0;
      add(1, 0);
      i = j - 1;
    }
    ans++;
  }
  cout << ans << endl;
}
