#include <bits/stdc++.h>
using namespace std;
void init() {}
const double EPS = 1e-9;
const int INF = (int)1e9 + 41;
const int N = 300300;
const int K = 26;
struct vertex {
  int next[K];
  int cnt = 0;
  long long hsh = 0;
  int len = 0;
  int pr = -1;
  bool lf = false;
};
const long long P = 1000000007;
vertex t[N];
long long h[N], deg[N];
int sz = 0;
void solve() {
  memset(t[0].next, 255, sizeof t[0].next);
  sz = 1;
  string s = "";
  char c;
  while (scanf("%c", &c) != EOF) {
    s += c;
  }
  int n = s.length();
  h[0] = 0;
  deg[0] = 1;
  for (int i = 0; i < n; i++) {
    h[i + 1] = h[i] * P + s[i];
    deg[i + 1] = deg[i] * P;
  }
  auto get_hash = [&](int l, int r) {
    return h[r + 1] - h[l] * deg[r - l + 1];
  };
  string cur = "";
  int ans = 0;
  int ps = 0;
  bool aut = false;
  for (int i = 0; i < n; i++) {
    if (!('a' <= s[i] && s[i] <= 'z')) {
      ans++;
      long long hs = get_hash(i - cur.length(), i - 1);
      bool cp = t[ps].lf;
      t[ps].lf = true;
      while (ps != -1) {
        if (!cp) t[ps].cnt++;
        t[ps].hsh = hs;
        t[ps].len = cur.length();
        ps = t[ps].pr;
      }
      ps = 0;
      aut = false;
      cur = "";
      continue;
    }
    int l = i - cur.length();
    int r = i - cur.length() + t[ps].len - 1;
    if (!aut && cur.length() > 0 && t[ps].cnt == 1 &&
        get_hash(l, r) == t[ps].hsh && cur.length() != t[ps].len) {
      aut = true;
      ans++;
      for (int q = i; q <= r; q++) {
        cur += s[q];
        ps = t[ps].next[s[q] - 'a'];
      }
      i = r;
      continue;
    }
    ans++;
    cur += s[i];
    if (t[ps].next[s[i] - 'a'] == -1) {
      memset(t[sz].next, 255, sizeof t[sz].next);
      t[sz].pr = ps;
      t[ps].next[s[i] - 'a'] = sz++;
      ps = sz - 1;
      continue;
    }
    ps = t[ps].next[s[i] - 'a'];
  }
  cout << ans;
}
int main() {
  init();
  solve();
  return 0;
}
