#include <bits/stdc++.h>
#pragma comment(linker, "/stack:156000000")
using namespace std;
const long long MOD = (long long)1e9 + 9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int MAXN = (int)6e5 + 5;
long long pr[MAXN];
long long H(char c) { return c - 'a' + 1; }
unordered_map<long long, pair<long long, long long> > pref;
unordered_multiset<long long> us;
long long str[MAXN];
vector<string> sl(0);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  long long ans = 0;
  pr[0] = 31;
  for (int i = 1; i < 500002; i++) pr[i] = (pr[i - 1] * 31) % MOD;
  while (getline(cin, s)) {
    s += "@";
    sl.resize(0);
    for (int i = 0; i < s.size(); i++) {
      string t = "";
      if (!isalpha(s[i]) && s[i] != '@') ans++;
      while (isalpha(s[i])) {
        t += s[i];
        i++;
      }
      if (t.size() > 0) {
        i--;
        sl.push_back(t);
      }
    }
    for (string t : sl) {
      str[0] = H(t[0]) * pr[0];
      for (int i = 1; i < t.size(); i++) {
        str[i] = (H(t[i]) * pr[i] + str[i - 1]) % MOD;
      }
      int le = -1, ri = t.size(), mi;
      while (ri - le > 1) {
        mi = (ri + le) / 2;
        if (us.count(str[mi]) <= 1)
          ri = mi;
        else
          le = mi;
      }
      if (le == -1 && us.count(str[0]) == 0) {
        ans += t.size();
        for (int i = 0; i < t.size(); i++) {
          us.insert(str[i]);
          pref[str[i]] = {str[t.size() - 1], t.size()};
        }
      } else {
        pair<long long, long long> pat = pref[str[ri]];
        if (pat.second > t.size()) {
          ans += t.size();
        } else {
          if (str[pat.second - 1] == pat.first) {
            ans += min(ri + 2ll + (long long)t.size() - pat.second,
                       (long long)t.size());
          } else {
            ans += t.size();
          }
        }
        if (pat.second != t.size()) {
          for (int i = ri; i < t.size(); i++) {
            us.insert(str[i]);
            pref[str[i]] = {str[t.size() - 1], t.size()};
          }
        } else {
          if (str[pat.second - 1] != pat.first)
            for (int i = ri; i < t.size(); i++) {
              us.insert(str[i]);
              pref[str[i]] = {str[t.size() - 1], t.size()};
            }
        }
      }
    }
    ans++;
  }
  cout << ans;
}
