#include <bits/stdc++.h>
using namespace std;
const int M = 10e9 + 7;
const int inf = 1000000000;
const int p1 = 31, p2 = 29;
long long ppow_p1 = 1, ppow_p2 = 1;
map<pair<int, int>, set<pair<int, int> > > m;
map<pair<int, int>, int> ret;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string kek, s = "&";
  while (true) {
    getline(cin, kek);
    if (kek == "") break;
    s += kek;
    s += "&";
  }
  s += "&";
  set<pair<int, int> > st;
  pair<int, int> now, dop;
  int beg = -1, one = -1, len = -1, answ = 0, when = -1;
  for (int c = 1; c < s.size() - 1; c++) {
    if (s[c] == '.' || s[c] == ',' || s[c] == '?' || s[c] == '!' ||
        s[c] == '\'' || s[c] == '-' || s[c] == ' ' || s[c] == '&') {
      if ((s[c - 1] == '.' || s[c - 1] == ',' || s[c - 1] == '?' ||
           s[c - 1] == '!' || s[c - 1] == '\'' || s[c - 1] == '-' ||
           s[c - 1] == ' ' || s[c - 1] == '&')) {
        answ++;
        continue;
      }
      answ += min((one >= beg ? c - beg + one - len - beg + 2 : inf), c - beg);
      ppow_p1 = 1;
      ppow_p2 = 1;
      dop.first = 0;
      dop.second = 0;
      for (int i = beg; i < c; i++) {
        dop.first += (s[i] - 'a' + 1) * ppow_p1;
        dop.first %= M;
        dop.second += (s[i] - 'a' + 1) * ppow_p2;
        dop.second %= M;
        ppow_p1 *= p1;
        ppow_p1 %= M;
        ppow_p2 *= p2;
        ppow_p2 %= M;
        m[dop].insert(now);
      }
      ret[now] = c - beg;
      answ++;
      ppow_p1 = 1;
      ppow_p2 = 1;
      now.first = 0;
      now.second = 0;
    } else {
      if ((s[c - 1] == '.' || s[c - 1] == ',' || s[c - 1] == '?' ||
           s[c - 1] == '!' || s[c - 1] == '\'' || s[c - 1] == '-' ||
           s[c - 1] == ' ' || s[c - 1] == '&'))
        beg = c;
      now.first += (s[c] - 'a' + 1) * ppow_p1;
      now.first %= M;
      now.second += (s[c] - 'a' + 1) * ppow_p2;
      now.second %= M;
      ppow_p1 *= p1;
      ppow_p1 %= M;
      ppow_p2 *= p2;
      ppow_p2 %= M;
      if (m[now].size() == 1 && one < beg) {
        len = ret[*m[now].begin()];
        if (when < beg) when = c;
        if (len > c - beg + 1) continue;
        one = when;
      }
    }
  }
  cout << answ;
  return 0;
}
