#include <bits/stdc++.h>
using namespace std;
struct node {
  unordered_map<char, int> next;
  int count = 0;
  bool is_end = false;
};
vector<node> nodes;
string s;
int get_next(int from, char c) {
  if (nodes[from].next[c] == 0) {
    nodes[from].next[c] = nodes.size();
    nodes.push_back(node());
  }
  return nodes[from].next[c];
}
pair<pair<int, bool>, pair<int, int> > try_skip(int from_node,
                                                int start_index) {
  int i = start_index;
  int next = get_next(from_node, s[i]);
  int prev = from_node;
  while (nodes[next].count == 1 && ++i < s.length()) {
    if (s[i] == ' ' || s[i] == '.' || s[i] == ',' || s[i] == '?' ||
        s[i] == '!' || s[i] == '\'' || s[i] == '-') {
      break;
    }
    prev = next;
    next = get_next(next, s[i]);
  }
  bool flag = i == s.length() || s[i] == ' ' || s[i] == '.' || s[i] == ',' ||
              s[i] == '?' || s[i] == '!' || s[i] == '\'' || s[i] == '-';
  if (flag) {
    prev = next;
  }
  if (nodes[prev].is_end) {
    return make_pair(make_pair(i - start_index - 1, flag), make_pair(i, prev));
  }
  return make_pair(make_pair(-1, false), make_pair(-1, -1));
}
int build() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int count = 0;
  int length = 0;
  int current_node = 0;
  bool can_skip = true;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] == ' ' || s[i] == '.' || s[i] == ',' || s[i] == '?' ||
        s[i] == '!' || s[i] == '\'' || s[i] == '-') {
      count += length + 1;
      length = 0;
      nodes[current_node].is_end = true;
      current_node = 0;
      can_skip = true;
      continue;
    }
    int next = get_next(current_node, s[i]);
    if (can_skip && nodes[next].count == 1) {
      pair<pair<int, bool>, pair<int, int> > skipped =
          try_skip(current_node, i);
      if (skipped.first.first < 2) {
        can_skip = false;
      } else {
        next = current_node;
        for (; i < skipped.second.first; ++i) {
          next = get_next(next, s[i]);
          if (!skipped.first.second) {
            ++nodes[next].count;
          }
        }
        --i;
        length += 2;
        current_node = next;
        continue;
      }
    }
    current_node = next;
    ++nodes[next].count;
    ++length;
  }
  count += length + 1;
  length = 0;
  nodes[current_node].is_end = true;
  current_node = 0;
  can_skip = true;
  return count;
}
void init() {
  nodes.clear();
  nodes.push_back(node());
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  init();
  int count = 0;
  while (getline(cin, s)) {
    if (s == "") {
      break;
    }
    count += build();
  }
  cout << count << "\n";
  return 0;
}
