#include <bits/stdc++.h>
struct TNode {
  bool is_terminal;
  int number_of_sons;
  std::map<char, int> sons;
  TNode() : is_terminal(false), number_of_sons(0), sons() {}
};
std::vector<TNode> trie;
int ans = 0;
int last_pref = 0;
std::vector<int> cur_word;
int process(int node, char c) {
  ans += 1;
  if (c < 'a' or c > 'z') {
    if (!trie[node].is_terminal) {
      trie[node].is_terminal = true;
      trie[node].number_of_sons += 1;
      for (int prev_node : cur_word) {
        trie[prev_node].number_of_sons += 1;
      }
    }
    node = 0;
    cur_word.clear();
    last_pref = 0;
  } else {
    cur_word.push_back(node);
    if (trie[node].sons.count(c)) {
      node = trie[node].sons[c];
      if (trie[node].number_of_sons > 1) {
        last_pref = cur_word.size();
      }
      if (trie[node].sons.size() == 0) {
        ans -= cur_word.size();
        ans += std::min(int(cur_word.size()), last_pref + 2);
      }
    } else {
      trie[node].sons[c] = trie.size();
      trie.emplace_back();
      node = trie.size() - 1;
    }
  }
  return node;
}
int main() {
  trie.emplace_back();
  int node = 0;
  trie[node].is_terminal = true;
  char c;
  while (scanf("%c", &c) == 1) {
    node = process(node, c);
  }
  printf("%d\n", ans);
}
