#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, INF = 1e9;
int Ans, nl, tot = 1;
char now[N], las, ch;
int tr[N][35], cn[N], flg[N];
int Is(char cc) { return cc >= 'a' && cc <= 'z'; }
int Could() {
  int t = 1;
  for (int i = 1; i <= nl; ++i) {
    int nc = now[i] - 'a';
    if (!tr[t][nc]) {
      if (cn[t] == 1 && flg[t] == 1) return 1;
      return 0;
    }
    t = tr[t][nc];
  }
  if (flg[t] == 1 && cn[t] == 1) return 1;
  return 0;
}
void Work() {
  int t = 1, fir = -1;
  for (int i = 1; i <= nl; ++i) {
    int nc = now[i] - 'a';
    if (!tr[t][nc]) {
      if (i - fir - 2 > 0) Ans -= i - fir - 2;
      return;
    }
    t = tr[t][nc];
    if (cn[t] == 1 && fir == -1) fir = i;
  }
  if (nl - fir - 1 > 0) Ans -= nl - fir - 1;
}
int Exist() {
  int t = 1;
  for (int i = 1; i <= nl; ++i) {
    int nc = now[i] - 'a';
    if (!tr[t][nc]) return 0;
    t = tr[t][nc];
  }
  return flg[t];
}
void Insert() {
  int t = 1;
  for (int i = 1; i <= nl; ++i) {
    int nc = now[i] - 'a';
    if (!tr[t][nc]) tr[t][nc] = ++tot;
    ++cn[t];
    t = tr[t][nc];
  }
  ++cn[t];
  ++flg[t];
}
int main() {
  las = '!';
  while (scanf("%c", &ch) == 1) {
    if (!Is(ch)) {
      ++Ans;
      if (Is(las)) {
        if (Could()) Work();
        if (!Exist()) Insert();
      }
      nl = 0;
    } else {
      ++Ans;
      now[++nl] = ch;
    }
    las = ch;
  }
  printf("%d\n", Ans);
  return 0;
}
