#include <bits/stdc++.h>
using namespace std;
long long const P = 239;
long long const P2 = 239017;
long long const MOD2 = 1000000007;
long long const LLINF = 1000000000000000000;
int const INF = 1000000000;
int const MAXN = 300002;
struct hashTable {
  vector<int> data;
  vector<int> bigH;
  long long mod;
  void init(int size) {
    mod = 4 * size + 1;
    data.resize(mod);
    bigH.resize(mod);
    for (int i = 0; i < (int)(mod); i++) {
      data[i] = bigH[i] = 0;
    }
  }
  void add(int hash, int bigHash, int x) {
    int k = hash;
    while (data[k] != 0 && bigH[k] != bigHash) {
      k = (k + 1) % mod;
    }
    if (data[k] != 0) {
      data[k] = -1;
    } else {
      data[k] = x;
      bigH[k] = bigHash;
    }
  }
  int get(int hash, int bigHash) {
    int k = hash;
    while (data[k] != 0 && bigH[k] != bigHash) {
      k = (k + 1) % mod;
    }
    if (data[k] == -1) {
      return 0;
    } else {
      return data[k];
    }
  }
};
vector<string> a;
hashTable ht[MAXN];
bool isPrefix(string &s, string &t) {
  for (int i = 0; i < (int)(s.length()); i++) {
    if (s[i] != t[i]) {
      return false;
    }
  }
  return true;
}
int add(string &s) {
  int res = s.length();
  a.push_back(s);
  int k = -1;
  long long hash = 0;
  long long bigHash = 0;
  for (int i = 0; i < (int)(s.length()); i++) {
    bigHash = (bigHash * P2 + s[i]) % MOD2;
    hash = bigHash % ht[i].mod;
    if (k == -1) {
      k = ht[i].get(hash, bigHash) - 1;
      if (k != -1 && a[k].length() > i + 1 && isPrefix(a[k], s)) {
        res -= a[k].length() - i - 2;
      }
    }
  }
  if (k == -1 || a[k] != s) {
    long long hash = 0;
    long long bigHash = 0;
    for (int i = 0; i < (int)(s.length()); i++) {
      bigHash = (bigHash * P2 + s[i]) % MOD2;
      hash = bigHash % ht[i].mod;
      ht[i].add(hash, bigHash, a.size());
    }
  }
  return res;
}
vector<string> ls;
int sz[MAXN];
int main() {
  int n, m;
  string t;
  string s = "";
  while (getline(cin, t)) {
    ls.push_back(t);
    string l = t;
    s = "";
    for (int i = 0; i < (int)(l.length()); i++) {
      if (l[i] == ' ' || l[i] == '.' || l[i] == ',' || l[i] == '?' ||
          l[i] == '!' || l[i] == '\'' || l[i] == '-') {
        if (s != "") {
          for (int i = 0; i < (int)(s.length()); i++) {
            sz[i]++;
          }
        }
        s = "";
      } else {
        s += l[i];
      }
    }
    if (s != "") {
      for (int i = 0; i < (int)(s.length()); i++) {
        sz[i]++;
      }
    }
  }
  for (int i = 0; i < (int)(MAXN); i++) {
    ht[i].init(sz[i] + 1);
  }
  int res = 0;
  for (int i = 0; i < (int)(ls.size()); i++) {
    string l = ls[i];
    s = "";
    for (int i = 0; i < (int)(l.length()); i++) {
      if (l[i] == ' ' || l[i] == '.' || l[i] == ',' || l[i] == '?' ||
          l[i] == '!' || l[i] == '\'' || l[i] == '-') {
        res++;
        if (s != "") {
          res += add(s);
        }
        s = "";
      } else {
        s += l[i];
      }
    }
    if (s != "") {
      res += add(s);
    }
    res++;
  }
  cout << res;
  return 0;
}
