#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
struct Node {
  Node *nextMass[27];
  char info;
  int level;
  int sonCol;
  Node *parent;
  Node(char a, int b) {
    for (int i(0); i < 27; i++) nextMass[i] = NULL;
    info = a;
    level = b;
    sonCol = 0;
    parent = NULL;
  }
};
void addVertex(Node *inz, Node *pattern) {
  inz->nextMass[(int)pattern->info - (int)'a'] = pattern;
  inz->sonCol++;
}
bool checkSon(Node *inz, char pattern) {
  if (inz->nextMass[(int)pattern - (int)'a'] != NULL)
    return true;
  else
    return false;
}
int main() {
  string st;
  Node *root = new Node(' ', 0);
  int answer(-1);
  while (true) {
    answer++;
    getline(cin, st);
    if (cin.fail()) break;
    bool wordStart = true;
    bool wordCreated = false;
    bool wasHere = false;
    Node *now = root;
    Node *lastShare = root;
    st += '#';
    for (int i(0); i < st.size(); i++) {
      if (st[i] == '.' || st[i] == ',' || st[i] == '?' || st[i] == '!' ||
          st[i] == '\'' || st[i] == '-' || st[i] == ' ' || st[i] == '#') {
        if (wordCreated) {
          if (now->nextMass[26] == NULL) {
            addVertex(now, new Node((char)((int)'z' + 1), now->level + 1));
            if (now->sonCol > 1) lastShare = now;
            now = now->nextMass[26];
          }
          wordCreated = false;
          if (wasHere) {
            int dif;
            if (now->sonCol == 1 && now->nextMass[26] != NULL)
              now = now->nextMass[26];
            else
              goto exit;
            dif = now->level - lastShare->level - 1 - 1;
            if (lastShare->sonCol > 1 || lastShare == root) dif--;
            if (dif > 0) answer -= dif;
          }
        }
      exit:
        wordStart = true;
        answer++;
        if (st[i] == '#') answer--;
        continue;
      }
      if (wordStart) {
        lastShare = root;
        wordCreated = true;
        wordStart = false;
        now = root;
      }
      if (checkSon(now, st[i])) {
        wasHere = true;
        if (now->sonCol != 1) lastShare = now;
        answer++;
        now = now->nextMass[(int)st[i] - (int)'a'];
      } else {
        if (now->sonCol == 1 && now->nextMass[26] != NULL) {
          int dif;
          dif = now->level - lastShare->level - 1 - 1;
          if (dif > 0) answer -= dif;
        }
        lastShare = now;
        Node *t = new Node(st[i], now->level + 1);
        addVertex(now, t);
        now = t;
        answer++;
      }
    }
  }
  cout << answer;
  return 0;
}
