#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1ll << 40;
char Char[1000001];
unordered_map<long long, bool> Mp;
unordered_map<long long, int> Edge;
int main(void) {
  ios::sync_with_stdio(false);
  register char First;
  register long long Digit = 0;
  register int Length = 0, Ans = 0, P = 0, Q = 0;
  while (1 == scanf("%c", &First)) {
    if (First >= 'a' && First <= 'z') {
      Digit = (Digit * 65539ll + First * 65537ll) % MOD;
      Char[++Length] = First;
      if (Mp[Digit]) P = Length;
      if (Edge[Digit] >= 2) Q = Length;
    } else {
      Ans += Length - P + min(P, Q + 2) + 1;
      if (!Mp[Digit]) {
        register int i;
        Mp[Digit] = true, Digit = 0;
        for (i = 1; i <= Length; i++)
          Digit = (Digit * 65539ll + Char[i] * 65537ll) % MOD, Edge[Digit]++;
      }
      Digit = P = Q = Length = 0;
    }
  }
  cout << Ans << endl;
  return 0;
}
