#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:108777216")
using namespace std;
int const MAX_N = 1024 * 1024;
char ms[MAX_N];
int ms_len = 0;
int rt[MAX_N];
long long ans = 0;
struct ptt {
  int sub_cnt;
  int nxt[26];
} trie[MAX_N];
int trie_len = 1;
void go(int& v, char ch, int& just_moved, int ad) {
  if (trie[v].nxt[ch - 'a'] > 0) {
    v = trie[v].nxt[ch - 'a'];
    just_moved = 1;
  } else {
    trie[v].nxt[ch - 'a'] = trie_len;
    v = trie_len;
    trie_len++;
    just_moved = 0;
  }
  trie[v].sub_cnt += ad;
}
set<string> mss;
void analyse_word(const string& word) {
  int not_such = 0;
  if (mss.find(word) == mss.end()) not_such = 1;
  mss.insert(word);
  int k = 0, v = 0;
  while (k < (int)word.length()) {
    ans++;
    int just_moved = 0;
    go(v, word[k], just_moved, not_such);
    if (trie[v].sub_cnt <= 1 + not_such && just_moved) {
      int loc_v = v;
      int loc_k = k + 1;
      int rt_len = 0;
      int fnd = 0;
      while (loc_k < (int)word.length())
        if (trie[loc_v].nxt[word[loc_k] - 'a'] > 0) {
          loc_v = trie[loc_v].nxt[word[loc_k] - 'a'];
          rt[rt_len++] = loc_v;
          loc_k++;
        } else {
          int is_move = 0;
          for (int ee = 0; ee < 26; ee++)
            if (trie[loc_v].nxt[ee] > 0) {
              is_move = 1;
              break;
            }
          if (!is_move) {
            for (int ee = 0; ee < rt_len; ee++)
              trie[rt[ee]].sub_cnt += not_such;
            if (rt_len) ans++;
            k = loc_k;
            v = loc_v;
            fnd = 1;
            break;
          } else {
            for (int ee = 0; ee < rt_len; ee++)
              trie[rt[ee]].sub_cnt += not_such;
            ans += loc_k - k - 1;
            k = loc_k;
            v = loc_v;
            fnd = 1;
            break;
          }
        }
      if (!fnd && loc_k >= (int)word.length()) {
        int is_move = 0;
        for (int ee = 0; ee < 26; ee++)
          if (trie[loc_v].nxt[ee] > 0) {
            is_move = 1;
            break;
          }
        if (!is_move) {
          for (int ee = 0; ee < rt_len; ee++) trie[rt[ee]].sub_cnt += not_such;
          if (rt_len) ans++;
          k = loc_k;
          v = loc_v;
          continue;
        } else {
          for (int ee = 0; ee < rt_len; ee++) trie[rt[ee]].sub_cnt += not_such;
          ans += loc_k - k - 1;
          k = loc_k;
          v = loc_v;
          continue;
        }
      }
    } else
      k++;
  }
}
int main() {
  while (!feof(stdin)) {
    char ch = getchar();
    if (feof(stdin)) break;
    ms[ms_len++] = ch;
  }
  ans = 0;
  string word = "";
  for (int i = 0; i < ms_len; i++)
    if ((ms[i] >= 'a' && ms[i] <= 'z') || (ms[i] >= 'A' && ms[i] <= 'Z'))
      word += ms[i];
    else {
      if (word.length() > 0) {
        analyse_word(word);
        word = "";
      }
      ans++;
    }
  if (word.length() > 0) {
    analyse_word(word);
    word = "";
  }
  cout << ans;
  return 0;
}
