#include <bits/stdc++.h>
using namespace std;
const int MAX_K = (int)26;
const int MAX_N = (int)3e5 + 100;
struct vertex {
  int lcnt;
  int next[MAX_K];
  bool leaf;
  vertex() : leaf(false), lcnt(0) {
    for (int i = 0; i < MAX_K; ++i) next[i] = -1;
  }
};
vertex t[MAX_N];
int sz;
void init() {
  t[0] = vertex();
  sz = 1;
}
char s[MAX_N];
pair<int, bool> check_string(const char *s, int n) {
  int res;
  bool found = true;
  int v = 0;
  char flag = 0;
  for (int i = 0; i < n; ++i) {
    char c = s[i] - 'a';
    if (t[v].next[c] == -1) {
      found = false;
      break;
    }
    v = t[v].next[c];
    if (flag != 2) {
      if (t[v].lcnt == 1 && flag == 0) {
        res = i + 2;
        flag = 1;
      }
      if (t[v].leaf && flag == 1) {
        res += n - i - 1;
        flag = 2;
      }
    }
  }
  if (!t[v].leaf) found = false;
  if (flag != 2) res = n;
  return make_pair(min(res, n), found);
}
void add_string(const char *s, int n) {
  int v = 0;
  for (int i = 0; i < n; ++i) {
    char c = s[i] - 'a';
    if (t[v].next[c] == -1) {
      t[sz] = vertex();
      t[v].next[c] = sz++;
    }
    ++t[v].lcnt;
    v = t[v].next[c];
  }
  t[v].leaf = true;
  ++t[v].lcnt;
}
int main() {
  int offset = 0;
  while (fgets(s + offset, MAX_N, stdin)) offset += strlen(s + offset);
  init();
  int n = offset;
  int l = 0, r = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '.' || s[i] == ',' || s[i] == '?' || s[i] == '!' ||
        s[i] == '\'' || s[i] == '-' || s[i] == ' ' || s[i] == '\n') {
      ++ans;
      r = i;
      if (r - l > 0) {
        pair<int, bool> res = check_string(s + l, r - l);
        ans += res.first;
        if (!res.second) add_string(s + l, r - l);
      }
      l = i + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
