#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int MAX = 300300;
map<char, int> g[MAX];
int en[MAX];
int BS = 1;
bool enb[MAX];
int calc(string& s) {
  int res = 0;
  int v = 0;
  int pos = -1;
  bool ad = false;
  for (int i = (0); i < ((int)s.size()); i++) {
    char c = s[i];
    if (i > 0 && en[v] == 1 && pos == -1) {
      pos = i;
    }
    if ((int)g[v].size() == 0 && pos > -1) {
      res -= max(0, i - pos - 1);
      pos = -1;
    }
    if (!g[v].count(s[i])) {
      pos = -1;
      g[v][s[i]] = BS++;
    }
    v = g[v][s[i]];
  }
  if (!enb[v]) {
    int v = 0;
    for (int i = (0); i < ((int)s.size()); i++) {
      v = g[v][s[i]];
      en[v]++;
    }
  }
  enb[v] = 1;
  if (pos != -1 && (int)g[v].size() == 0) {
    res -= (int)s.size() - pos - 1;
  }
  return res;
}
int main() {
  char c;
  string cur = "";
  int ans = 0;
  int mn = 0;
  while ((c = getchar()) != EOF) {
    ans++;
    if (islower(c)) {
      cur += c;
    } else {
      mn += calc(cur);
      cur = "";
    }
  }
  mn += calc(cur);
  cout << ans + mn;
}
