#include <bits/stdc++.h>
using namespace std;
int trie[300010][27];
int flag[300010];
int main() {
  char ch;
  int now = 0, sum = 0, res = -1, len = 0, ans = 0, last = 0;
  while (scanf("%c", &ch) == 1) {
    if (ch >= 'a' && ch <= 'z') {
      if (trie[now][ch - 'a' + 1] == 0)
        trie[now][ch - 'a' + 1] = ++sum, flag[sum] = -1;
      trie[trie[now][ch - 'a' + 1]][0]++;
      if (trie[now][0] != trie[trie[now][ch - 'a' + 1]][0] &&
          trie[trie[now][ch - 'a' + 1]][0] > 1)
        res = len;
      last = now, now = trie[now][ch - 'a' + 1];
      if (res == -1) ans++;
      len++;
      if (trie[now][0] == 1 && res != -1) {
        if (flag[last] == 1)
          ans += min(len, (res + 3));
        else
          ans += len;
        res = -1;
      }
      flag[last] = 0;
    } else {
      if (res != -1)
        if (flag[now])
          ans += min(len, (res + 2));
        else
          ans += len;
      if (flag[now] == -1) flag[now] = 1;
      len = 0, res = -1, now = 0;
      ans++;
    }
  }
  printf("%d", ans);
  return 0;
}
