#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& v) {
  is >> v.first >> v.second;
  return is;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& v) {
  os << "{";
  os << v.first << ", " << v.second;
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, map<T1, T2>& v) {
  os << "{";
  int i = 0;
  for (auto a : v) {
    os << a;
    if (i != v.size() - 1) os << " ";
    ++i;
  }
  os << "}" << '\n';
  return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (int i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i != v.size() - 1) os << " ";
  }
  os << "]" << '\n';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    os << v[i];
    if (i != v.size() - 1) os << " ";
  }
  os << "]" << '\n';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& v) {
  os << "[";
  int i = 0;
  for (auto a : v) {
    os << a;
    if (i != v.size() - 1) os << " ";
  }
  os << "]" << '\n';
  return os;
}
struct Node {
  vector<Node*> childs;
  Node* parent;
  bool unique = true;
  bool endfWord = false;
  int endOfWord = 0;
  Node(Node* p) {
    parent = p;
    childs.resize(26, NULL);
  }
  Node* goTo(char c) {
    int index = c - 'a';
    if (!childs[index]) {
      childs[index] = new Node(this);
    }
    return childs[index];
  }
  void endOfWordFunc() {
    if (endfWord) {
      return;
    }
    endfWord = true;
    Node* p = this;
    bool un = true;
    while (p) {
      p->endOfWord += 1;
      un &= p->endOfWord <= 1;
      p->unique = un;
      p = p->parent;
    }
  }
};
Node* root;
int main(int argc, char** argv) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  root = new Node(NULL);
  char c;
  Node* cur = root;
  int steps = 0;
  int lastUniqSteps = -1;
  while ((c = getchar()) != EOF) {
    bool isNew = false;
    if ('a' <= c && c <= 'z') {
      isNew = cur->childs[c - 'a'] == NULL;
      cur = cur->goTo(c);
      ++steps;
    } else {
      lastUniqSteps = -1;
      cur->endOfWordFunc();
      cur = root;
      ++steps;
    }
    if (cur != root) {
      if (lastUniqSteps == -1 && cur->unique && cur->endOfWord > 0) {
        lastUniqSteps = steps;
      } else if (cur->unique && !isNew && cur->endfWord) {
        steps = lastUniqSteps + 1;
      }
    }
  }
  cout << steps << '\n';
  return 0;
}
