#include <bits/stdc++.h>
using namespace std;
bool bookva(const char& c) { return ((c >= 'a') && (c <= 'z')); }
const int &M1 = 1000000007, P1 = 85782, M2 = 1000000009, P2 = 67891;
int umn(const long long& a, const long long& b, const long long& m) {
  return (a * b) % m;
}
int slo(const int& a, const int& b, const int& m) {
  int c = a + b;
  return (c >= m ? c - m : c);
}
void add_visit(set<pair<int, int> >& vis, const string& word) {
  pair<int, int> h(0, 0);
  int i = 0, n = ((int)(word.size())), s1 = 1, s2 = 1;
  while (i < n) {
    h = pair<int, int>(slo(h.first, umn(s1, word[i], M2), M1),
                       slo(h.second, umn(s2, word[i], M2), M2));
    s1 = umn(s1, P1, M1);
    s2 = umn(s2, P2, M2);
    vis.insert(h);
    ++i;
  }
}
int dictionarify(vector<string>& words, map<pair<int, int>, int>& dict,
                 set<pair<int, int> >& vis, const string& word) {
  pair<int, int> h(0, 0);
  int i = 0, n = ((int)(word.size())), s1 = 1, s2 = 1;
  while ((i < n) &&
         ((vis.find(h) != vis.end()) && (dict.find(h) == dict.end()))) {
    h = pair<int, int>(slo(h.first, umn(s1, word[i], M2), M1),
                       slo(h.second, umn(s2, word[i], M2), M2));
    s1 = umn(s1, P1, M1);
    s2 = umn(s2, P2, M2);
    ++i;
  }
  auto aut = dict.find(h);
  if (aut != dict.end()) {
    int numb_u = aut->second;
    int m = ((int)(words[numb_u].size()));
    int k = min(m, n);
    if (words[numb_u] == word) return min(n, i + 1);
    int numb_word = ((int)(words.size()));
    words.push_back(word);
    dict.erase(aut);
    int j = i;
    while ((i < k) && (words[numb_u][i] == word[i])) {
      h = pair<int, int>(slo(h.first, umn(s1, word[i], M2), M1),
                         slo(h.second, umn(s2, word[i], M2), M2));
      s1 = umn(s1, P1, M1);
      s2 = umn(s2, P2, M2);
      ++i;
    }
    if (i == n) {
      h = pair<int, int>(slo(h.first, umn(s1, words[numb_u][i], M2), M1),
                         slo(h.second, umn(s2, words[numb_u][i], M2), M2));
      dict.insert({h, numb_u});
      return n;
    } else if (i == m) {
      h = pair<int, int>(slo(h.first, umn(s1, word[i], M2), M1),
                         slo(h.second, umn(s2, word[i], M2), M2));
      dict.insert({h, numb_word});
      add_visit(vis, word);
      int first_word = min(m, j + 1);
      return first_word + (n - m);
    } else {
      pair<int, int> h1 =
          pair<int, int>(slo(h.first, umn(s1, words[numb_u][i], M2), M1),
                         slo(h.second, umn(s2, words[numb_u][i], M2), M2));
      dict.insert({h1, numb_u});
      h = pair<int, int>(slo(h.first, umn(s1, word[i], M2), M1),
                         slo(h.second, umn(s2, word[i], M2), M2));
      dict.insert({h, numb_word});
      add_visit(vis, word);
      return n;
    }
  }
  if (vis.find(h) == vis.end()) {
    int numb_word = ((int)(words.size()));
    words.push_back(word);
    dict.insert({h, numb_word});
    add_visit(vis, word);
    return n;
  }
  return n;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  int ans = 0;
  map<pair<int, int>, int> dict;
  vector<string> words;
  set<pair<int, int> > vis;
  vis.insert({0, 0});
  while (getline(cin, s)) {
    ++ans;
    int n = ((int)(s.size()));
    for (int i = 0; i < n; ++i)
      if (bookva(s[i])) {
        string word(1, s[i]);
        int j = i;
        while (bookva(s[++j])) word.push_back(s[j]);
        ans += dictionarify(words, dict, vis, word);
        i = j - 1;
      } else
        ++ans;
  }
  cout << ans << '\n';
  return 0;
}
