#include <bits/stdc++.h>
using namespace std;
struct bor {
  map<char, int> next;
  int prev;
  bool lable;
};
set<char> sign = {',', '.', '-', '?', '!', '\'', ' '};
string s, s_;
vector<bor> all;
int ot, now, ret, v = -1;
int main() {
  while (getline(cin, s_)) s += s_ + " ";
  all.push_back({{}, 0, true});
  ot = s.size();
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (sign.count(c)) {
      ret = all[ret].prev;
      while ((!all[ret].lable) && (all[ret].next.size() < 2)) {
        ret = all[ret].prev;
        v++;
      }
      if (v > 0) ot -= v;
      all[now].lable = true;
      ret = now = 0;
      v = -1;
    } else {
      if (!all[now].next.count(c)) {
        all[now].next[c] = all.size();
        all.push_back({{}, now, false});
      }
      now = all[now].next[c];
      if ((all[now].lable) && (all[now].next.size() == 0)) ret = now;
    }
  }
  cout << ot;
}
