#include <bits/stdc++.h>
using namespace std;
struct Node {
  int par = -1;
  unordered_map<char, int> go;
  int sum = 0;
  bool leaf = false;
};
const int MX_SZ = 3e+5 + 42;
int first_free = 1;
vector<Node> tr(MX_SZ);
vector<string> read(int &answer) {
  string s = "";
  string t;
  while (getline(cin, t)) {
    s += t;
    s += '\n';
  }
  vector<string> ret;
  ret.push_back("");
  bool is_word = false;
  for (char c : s) {
    if (!isalpha(c)) {
      if (is_word) {
        ret.push_back("");
      }
      is_word = false;
      ++answer;
    } else {
      ret.back() += c;
      is_word = true;
    }
  }
  if (!ret.empty()) {
    ret.pop_back();
  }
  return ret;
}
void create_node(int par, char c) {
  tr[par].go[c] = first_free;
  tr[first_free].par = par;
  ++first_free;
}
void add_one(int v) {
  ++tr[v].sum;
  v = tr[v].par;
  if (v != -1) {
    add_one(v);
  }
}
void go(int &v, char c) {
  if (!tr[v].go.count(c)) {
    create_node(v, c);
  }
  v = tr[v].go[c];
}
void read_string(const vector<string> &words, int &answer) {
  int cur_v = 0;
  int cur_word = 0;
  vector<bool> was_skipped(MX_SZ, false);
  for (auto word : words) {
    bool try_ = false;
    for (int i = 0; i < word.size(); ++i) {
      if (!try_ and tr[cur_v].sum == 1 and cur_v != 0) {
        int tmp_v = cur_v;
        int ind = i;
        while (tr[tmp_v].go.size() > 0 and tr[tmp_v].go.count(word[ind]) and
               ind < word.size()) {
          tmp_v = tr[tmp_v].go[word[ind]];
          ++ind;
        }
        if (ind - i > 0 and (tr[tmp_v].go.empty() or
                             (ind == word.size() and tr[tmp_v].go.empty()))) {
          ++answer;
          i = ind;
          cur_v = tmp_v;
        }
        try_ = true;
      }
      if (i == word.size()) {
        break;
      }
      ++answer;
      go(cur_v, word[i]);
    }
    if (!tr[cur_v].leaf) {
      tr[cur_v].leaf = true;
      add_one(cur_v);
    }
    ++cur_word;
    cur_v = 0;
  }
}
int main() {
  int answer = 0;
  auto words = read(answer);
  read_string(words, answer);
  cout << answer << endl;
}
