Arcady is a copywriter. His today's task is to type up an already well-designed story using his favorite text editor.

Arcady types words, punctuation signs and spaces one after another. Each letter and each sign (including line feed) requires one keyboard click in order to be printed. Moreover, when Arcady has a non-empty prefix of some word on the screen, the editor proposes a possible autocompletion for this word, more precisely one of the already printed words such that its prefix matches the currently printed prefix if this word is unique. For example, if Arcady has already printed «codeforces», «coding» and «codeforces» once again, then there will be no autocompletion attempt for «cod», but if he proceeds with «code», the editor will propose «codeforces».

With a single click Arcady can follow the editor's proposal, i.e. to transform the current prefix to it. Note that no additional symbols are printed after the autocompletion (no spaces, line feeds, etc). What is the minimum number of keyboard clicks Arcady has to perform to print the entire text, if he is not allowed to move the cursor or erase the already printed symbols?

A word here is a contiguous sequence of latin letters bordered by spaces, punctuation signs and line/text beginnings/ends. Arcady uses only lowercase letters. For example, there are 20 words in «it's well-known that tic-tac-toe is a paper-and-pencil game for two players, x and o.».


-----Input-----

The only line contains Arcady's text, consisting only of lowercase latin letters, spaces, line feeds and the following punctuation signs: «.», «,», «?», «!», «'» and «-». The total amount of symbols doesn't exceed 3·10^5. It's guaranteed that all lines are non-empty.


-----Output-----

Print a single integer — the minimum number of clicks.


-----Examples-----
Input
snow affects sports such as skiing, snowboarding, and snowmachine travel.
snowboarding is a recreational activity and olympic and paralympic sport.

Output
141

Input
'co-co-co, codeforces?!'

Output
25

Input
thun-thun-thunder, thunder, thunder
thunder, thun-, thunder
thun-thun-thunder, thunder
thunder, feel the thunder
lightning then the thunder
thunder, feel the thunder
lightning then the thunder
thunder, thunder

Output
183



-----Note-----

In sample case one it's optimal to use autocompletion for the first instance of «snowboarding» after typing up «sn» and for the second instance of «snowboarding» after typing up «snowb». This will save 7 clicks.

In sample case two it doesn't matter whether to use autocompletion or not.

Difficulty: interview

Starter code:

Solutions:
class Ddict:
    def __init__(self):
        self.dicts={}
    def add(self,key):
        d=self.dicts
        for i in key:
            if i not in d:
                d[i]={}
            d=d[i]
        d[' ']=''
    def find(self,key):
        if key=='':
            return '',''
        d=self.dicts
        q=[]
        h=[key[0]]
        for i in key:
            if i not in d:
                if ' ' in d and len(d)==1:
                    return ''.join(q),''.join(h)
                return '',''
            q.append(i)
            if len(d)!=1:
                h=q[:]
            d=d[i]
        if ' ' in d and len(d)==1:
            return ''.join(q),''.join(h)
        return '',''
words = Ddict()
ans=0
while True:
    try:
        x=input()
        if not x:
            break
    except:
        break
    ans+=len(x)+1
    ws=[[]]
    for i in x:
        if i in '.,?!\'- ':
            if ws[-1]:
                ws.append([])
        else:
            ws[-1].append(i)
    ws=list([''.join(e) for e in ws])
    for w in ws:
        next_word,helped_word = words.find(w)
        if next_word and next_word!=helped_word:
            ans-=len(next_word)-len(helped_word)-1
        words.add(w)
print(ans)


# python3
# utf-8

class Trie:
    def __init__(self):
        self.letter___node = {}
        self.words_nr = 0

    def add_word(self, word):
        word = word + '$'
        curr_node = self
        for letter in word:
            if letter not in curr_node.letter___node:
                curr_node.letter___node[letter] = Trie()
            curr_node.words_nr += 1
            curr_node = curr_node.letter___node[letter]

    def check_word(self, word):
        word = word + '$'
        curr_node = self
        for letter in word:
            if letter not in curr_node.letter___node:
                return False
            curr_node = curr_node.letter___node[letter]
        return True

    def count_word(self, word):
        word = word + '$'
        curr_node = self
        curr_state = 0
        presses_saved = 0
        for letter in word:
            if letter not in curr_node.letter___node:
                if curr_state == 1:
                    # print(presses_saved)
                    if '$' in curr_node.letter___node:
                        return min(len(word) - 1,
                            len(word) - 1 - presses_saved + 1
                        )
                    else:
                        return len(word) - 1
                if curr_state == 0:
                    return len(word) - 1
            if curr_node.words_nr > 1:
                curr_node = curr_node.letter___node[letter]
            elif curr_node.words_nr == 1:
                # print(letter, presses_saved)
                if curr_state == 0:
                    curr_state = 1
                presses_saved += 1
                curr_node = curr_node.letter___node[letter]
            elif curr_node.words_nr == 0:
                if curr_state == 1:
                    return min(len(word) - 1,
                        len(word) - 1 - presses_saved + 1
                    )
                elif curr_state == 0:
                    return len(word) - 1
        if curr_node.words_nr == 0:
            presses_saved -= 1
            if curr_state == 1:
                return min(len(word) - 1,
                    len(word) - 1 - presses_saved + 1
                )
            elif curr_state == 0:
                return len(word) - 1




text = ''
while(1):
    try:
        line = input()
        if line == '':
            raise Exception('e')
        text += line + '\n'
    except:
        break
# print(text)
ans = 0
syms = ['\n', '.', ',', '?', '!', "'", '-']
for sym in syms:
    text = text.replace(sym, ' ')
ans += text.count(' ')
idx___word = text.split(' ')
root = Trie()
root.add_word('$')
root.add_word('$$')
for word in idx___word:
    if word == '':
        continue
    count = root.count_word(word)
    check = root.check_word(word)
    # print(word, check, count)
    ans += count
    if not check:
        root.add_word(word)

print(ans)


import sys
import re

SEPARATORS = "[.,? !'-]"

class TrieNode(object):
    def __init__(self):
        self.terminal = False
        self.go = {}
        self.count = 0

def insert(node, s):
    nodes = [node]
    unique, auto = 0, 0
    for c in s:
        if c not in node.go:
            node.go[c] = TrieNode()
        node = node.go[c]
        nodes.append(node)
        
        if node.count == 1:
            unique += 1
        if node.terminal:
            auto = max(unique - 2, 0)
            
    if not node.terminal:
        node.terminal = True
        for node in nodes:
            node.count += 1
    return auto

root = TrieNode()
answer = 0
for line in sys.stdin:
    answer += len(line)
    for word in [_f for _f in re.split(SEPARATORS, line.strip()) if _f]:
        answer -= insert(root, word)
print(answer)


import sys
import re

SEPARATORS = "[.,? !'-]"

class TrieNode(object):
    def __init__(self):
        self.terminal = False
        self.go = {}
        self.count = 0

def insert(node, s):
    nodes = [node]
    unique, auto = 0, 0
    for c in s:
        if c not in node.go:
            node.go[c] = TrieNode()
        node = node.go[c]
        nodes.append(node)
        
        if node.count == 1:
            unique += 1
        if node.terminal:
            auto = max(unique - 2, 0)
            
    if not node.terminal:
        node.terminal = True
        for node in nodes:
            node.count += 1
    return auto

root = TrieNode()
answer = 0
for line in sys.stdin:
    answer += len(line)
    for word in [_f for _f in re.split(SEPARATORS, line.strip()) if _f]:
        answer -= insert(root, word)
print(answer)