#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto i : v) os << i << " ";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, set<T>& v) {
  for (auto i : v) os << i << " ";
  return os;
}
template <class T, class R>
ostream& operator<<(ostream& os, pair<T, R>& v) {
  os << '(' << v.first << ' ' << v.second << ')' << ' ';
  return os;
}
struct Bor {
  int len;
  int cnt;
  int go[26];
  Bor() {
    for (size_t i = 0; i < 26; ++i) go[i] = -1;
    cnt = 0;
  }
};
int nxt = 1;
long long ans = 0;
const int N = 6e5;
Bor bor[N];
const long long mod = 1e9 + 409;
const long long p = 31;
set<long long> was;
long long getHash(const string& s) {
  long long hash = 0;
  long long w = 1;
  for (char c : s) {
    hash = (hash + (c - 'a' + 1) * w) % mod;
    w = (w * p) % mod;
  }
  return hash;
}
void solve(const string& s) {
  int v = 0;
  bool fl = false;
  for (size_t i = 0; i < s.size(); ++i) {
    int k = s[i] - 'a';
    if (bor[v].go[k] == -1) {
      fl = false;
      break;
    } else {
      v = bor[v].go[k];
    }
    if (i + 1 != s.size() && bor[v].cnt == 1) {
      if (bor[v].len > (s.size() - i - 1)) {
        fl = false;
        break;
      }
      int w = v;
      int j = i + 1;
      while (true) {
        if (bor[w].go[s[j] - 'a'] == -1) {
          fl = false;
          break;
        }
        w = bor[w].go[s[j] - 'a'];
        if (bor[w].len == 0) {
          ans += i + 2;
          ans += s.size() - j - 1;
          fl = true;
          break;
        }
        ++j;
      }
      break;
    }
  }
  if (!fl) {
    ans += s.size();
  }
  long long hs = getHash(s);
  if (was.count(hs)) return;
  was.insert(hs);
  v = 0;
  for (size_t i = 0; i < s.size(); ++i) {
    int k = s[i] - 'a';
    if (bor[v].go[k] == -1) {
      bor[v].go[k] = nxt;
      bor[nxt].cnt = 0;
      nxt++;
    }
    v = bor[v].go[k];
    ++bor[v].cnt;
    if (bor[v].cnt == 1) {
      bor[v].len = (int)s.size() - (int)i - 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  char c;
  while (c = getchar()) {
    if (c == -1) break;
    if (c >= 'a' && c <= 'z')
      s += c;
    else {
      ++ans;
      if (s == "") continue;
      solve(s);
      s = "";
    }
  }
  if (s != "") solve(s);
  cout << ans << endl;
}
