#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)5e5 + 228;
const char nxtl = '\n';
const int mod = (int)1e9 + 7;
const double eps = (double)1e-7;
template <typename T>
inline bool updmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool updmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
string tmp;
int t[30][MAXN * 3], sz, cnt[MAXN * 3], have[MAXN * 3];
bool _end[MAXN * 3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(t, 255, sizeof t);
  int res = 0;
  while (getline(cin, tmp)) {
    res++;
    for (int i = 0; i <= ((int)(tmp.size())) - 1; ++i) {
      if (!isalpha(tmp[i])) {
        res++;
        continue;
      }
      int j = i;
      int v = 0;
      bool ok = 1;
      while (j < ((int)(tmp.size())) && isalpha(tmp[j])) j++;
      j--;
      int mn = j - i + 1, bgn = j + 1;
      for (int k = i; k <= j; ++k) {
        int c = tmp[k] - 'a';
        if (t[c][v] == -1) {
          ok = 0;
          break;
        }
        v = t[c][v];
        if (cnt[v] == 1) updmin(bgn, k);
        if (_end[v] && cnt[v] == 1) {
          updmin(mn, 1 + (j - k) + (bgn - i + 1));
        }
      }
      res += mn;
      if (ok && _end[v]) {
        i = j;
        continue;
      }
      v = 0;
      for (int k = i; k <= j; ++k) {
        int c = tmp[k] - 'a';
        if (t[c][v] == -1) t[c][v] = ++sz;
        v = t[c][v];
        cnt[v]++;
      }
      _end[v] = 1;
      i = j;
    }
  }
  cout << res;
  return 0;
}
