#include <bits/stdc++.h>
using namespace std;
inline bool isLetter(char c) { return c >= 'a' && c <= 'z'; }
struct Trie {
  bool ends_here = false;
  int elem_count = 0;
  Trie* father = nullptr;
  vector<Trie*> childs;
  string construct_postfix() {
    if (ends_here) {
      return "";
    }
    for (int i = 0; i < childs.size(); ++i) {
      if (childs[i] != nullptr) {
        return string(1, char(i + 'a')) + childs[i]->construct_postfix();
      }
    }
  }
};
int main() {
  vector<char> s;
  s.reserve(5 * 100 * 1000);
  int tmp;
  while (tmp = getchar()) {
    if (tmp == '#') break;
    if (tmp == EOF) break;
    s.push_back(tmp);
  }
  Trie root;
  Trie* current_state = &root;
  bool tried_postfix = false;
  int answer = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (isLetter(s[i])) {
      char number = s[i] - 'a';
      if (current_state->childs.size() > number &&
          current_state->childs[number] != nullptr) {
        current_state = current_state->childs[number];
        if (!tried_postfix && current_state->elem_count == 1 &&
            !current_state->ends_here) {
          tried_postfix = true;
          string postfix = current_state->construct_postfix();
          bool is_equal = true;
          for (int j = 0; j < postfix.size(); ++j) {
            if (s[i + j + 1] != postfix[j]) {
              is_equal = false;
              break;
            }
          }
          if (is_equal) {
            i = i + postfix.size();
            for (char letter : postfix) {
              current_state = current_state->childs[letter - 'a'];
            }
            answer++;
          }
        }
      } else {
        if (current_state->childs.size() <= number) {
          current_state->childs.resize(number + 1);
        }
        current_state->childs[number] = new Trie();
        current_state->childs[number]->father = current_state;
        current_state = current_state->childs[number];
      }
    } else {
      if (current_state != &root && current_state->ends_here == false) {
        current_state->ends_here = true;
        while (current_state != &root) {
          current_state->elem_count++;
          current_state = current_state->father;
        }
      } else {
        current_state = &root;
      }
      tried_postfix = false;
    }
    ++answer;
  }
  cout << answer << endl;
  return 0;
}
