#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e6 + 10;
int n, ans, sz;
char t[MAXN];
struct Node {
  int cnt;
  map<char, int> next;
  int link;
};
Node st[MAXN];
void init() {
  st[0].cnt = 2;
  st[0].link = -1;
  sz++;
  ans = 0;
}
void inc(int v) {
  while (v > 0) {
    st[v].cnt++;
    v = st[v].link;
  }
}
pair<int, int> comp(int i) {
  int v = 0;
  int res = 0;
  while (st[v].cnt > 1 && i < n && st[v].next.count(t[i])) {
    v = st[v].next[t[i]];
    res++;
    i++;
  }
  if (i == n || !('a' <= t[i] && t[i] <= 'z')) {
    if ((int)st[v].next.size() != 0) inc(v);
    return make_pair(res, i);
  } else {
    int res2 = 0;
    while (i < n && st[v].next.count(t[i])) {
      v = st[v].next[t[i]];
      res2++;
      i++;
    }
    if (i == n || !('a' <= t[i] && t[i] <= 'z')) {
      if ((int)st[v].next.size() == 0) {
        return make_pair(res + 1, i);
      } else {
        inc(v);
        return make_pair(res + res2, i);
      }
    } else {
      if ((int)st[v].next.size() == 0) {
        res += min(res2, 1);
      } else {
        res += res2;
      }
      while (i < n && 'a' <= t[i] && t[i] <= 'z') {
        st[v].next[t[i]] = sz;
        st[sz].link = v;
        v = sz++;
        res++;
        i++;
      }
      inc(v);
      return make_pair(res, i);
    }
  }
}
int main() {
  init();
  while (gets(t)) {
    ans++;
    n = strlen(t);
    for (int i = 0; i < n;) {
      if ('a' <= t[i] && t[i] <= 'z') {
        pair<int, int> res = comp(i);
        ans += res.first;
        i = res.second;
      } else {
        i++;
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
