#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
vector<char> text;
int ans = 0;
vector<string> word;
map<char, bool> ch;
string s_new;
void prep() {
  ch['.'] = 1;
  ch[','] = 1;
  ch['?'] = 1;
  ch['!'] = 1;
  ch['-'] = 1;
  ch[39] = 1;
  ch[' '] = 1;
  ch['\n'] = 1;
  return;
}
void text_in() {
  char c = getchar();
  while (c != EOF) {
    text.push_back(c);
    c = getchar();
  }
  return;
}
void make_words() {
  string s = "";
  for (int i = 0; i < text.size(); i++) {
    if (ch[text[i]] == 1) {
      if (s.size() > 0) {
        word.push_back(s);
      }
      s = "";
      ans++;
    } else {
      s += text[i];
    }
  }
  if (s.size() > 0) {
    word.push_back(s);
  }
  return;
}
struct trie {
  int num_words;
  bool if_end;
  map<int, trie *> to;
  trie() {
    num_words = 0;
    if_end = 0;
  }
};
trie *t = new trie();
pair<int, int> check(string &s) {
  trie *v = t;
  int pos = 0;
  for (int i = 0; i < s.size(); i++) {
    if (v->to[s[i] - 'a'] == NULL) {
      return make_pair(-1, -1);
    }
    v = v->to[s[i] - 'a'];
    if (v->num_words == 1) {
      pos = i;
      break;
    }
  }
  int pp = pos;
  if (v->num_words > 1) return make_pair(-1, -1);
  if (v->num_words == 1 && v->if_end == true)
    return make_pair(pp + 1, s.size() - pp - 1);
  for (int i = pp + 1; i < s.size(); i++) {
    if (v->to[s[i] - 'a'] == NULL) {
      return make_pair(-1, -1);
    }
    v = v->to[s[i] - 'a'];
    if (v->if_end == true) {
      return make_pair(pp + 1, s.size() - i - 1);
    }
  }
  if (v->if_end == false || v->num_words > 1) return make_pair(-1, -1);
  if (pp != -1)
    return make_pair(pp + 1, s.size() - pp - 1);
  else
    return make_pair(-1, -1);
}
void build(string &s) {
  trie *v = t;
  for (int i = 0; i < s.size(); i++) {
    if (v->to[s[i] - 'a'] == NULL) {
      v->to[s[i] - 'a'] = new trie();
    }
    v = v->to[s[i] - 'a'];
    v->num_words++;
  }
  v->if_end = true;
  return;
}
bool prov(string &s) {
  trie *v = t;
  for (int i = 0; i < s.size(); i++) {
    if (v->to[s[i] - 'a'] == NULL) {
      return true;
    }
    v = v->to[s[i] - 'a'];
  }
  if (v->if_end == true)
    return false;
  else
    return true;
}
int main() {
  prep();
  text_in();
  make_words();
  for (int i = 0; i < word.size(); i++) {
    pair<int, int> num = check(word[i]);
    if (num.first != -1)
      ans += min(num.first + num.second + 1, (int)word[i].size());
    else
      ans += word[i].size();
    if (prov(word[i])) build(word[i]);
  }
  cout << ans;
  return 0;
}
