#include <bits/stdc++.h>
using namespace std;
struct output {};
struct input {};
template <typename T>
output operator,(output l, const T& r) {
  cout << r;
  return l;
}
template <typename T>
input operator,(input l, T& r) {
  cin >> r;
  return l;
}
input I;
output P;
inline long long In() {
  static long long v;
  I, v;
  return v;
}
char sp = ' ', nl = '\n';
const long long SZ = 4e5 + 10, AL = 26;
long long nxt[SZ][AL], prv[SZ], cnt[SZ], wait[SZ];
long long ans = 0, bri = 0, root = 0;
char buf[SZ];
long long brgo(long long v, char c) {
  if (nxt[v][c] == -1) {
    nxt[v][c] = ++bri;
    prv[bri] = v;
  }
  return nxt[v][c];
}
void count(long long v) {
  for (long long vv = v; v != -1; v = prv[v]) {
    if (cnt[v] == 0)
      cnt[v] = vv;
    else if (cnt[v] != vv)
      cnt[v] = -1;
  }
}
int sep(char c) { return c < 'a' || c > 'z'; }
int main() {
  for (long long i = (0); i < (SZ); i++) {
    for (long long j = (0); j < (AL); j++) nxt[i][j] = -1;
    prv[i] = -1;
  }
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  set<long long> targets;
  long long length = 0;
  for (char c = getchar(); c != EOF; c = getchar()) {
    if (sep(c)) {
      count(root);
      ans += length + 1;
      targets.clear();
      root = 0;
      length = 0;
    } else {
      length++;
      root = brgo(root, c);
      if (cnt[root] != 0 && cnt[root] != -1) {
        long long t = cnt[root];
        if (!targets.count(t)) {
          targets.insert(t);
          wait[t] = length;
        } else
          wait[t] = min(length, wait[t]);
      } else
        wait[root] = 1e17;
      if (wait[root] < length) length = wait[root] + 1;
    }
  }
  P, ans, nl;
}
