1570 - Lazy. Lazy. Laaaaaaaaaaaazy!

Time Limit: 1s Memory Limit: 128MB

Submissions: 425 Solved: 138
Description
         YangShen is very lazy. One day, he received a typing task from his leader Mr. He, which is non-technical, time-wasteful and as boring as possible. As this, YangShen, the laziest one in the world, want to know an easy way to finish the typing task.
         The key-board that Mr. He provided is a little similar with the key-board that we are familiar with. There is one SHIFT, one CAPS LOCK and some other NORMAL keys on the key-board, each normal key can input two different chars, one is when the CAPS LOCK is on, another is when the CAPS LOCK is off. It will toggle the input char when pressing SHIFT while input with a NORMAL key. The initial state of CAPS LOCK is off.
         Lazy YangShen want to know the minimum times that he must pressing the keys.
Input
    multiple case, please process to EOF.
    In each case, there are three strings separated by single space. the first, which is the chars input by NORMAL keys when CAPS LOCK is on; the second, which is the chars input by NORMAL keys when CAPS LOCK is off; the third is the text content that Mr. He ask YangShen to typing.
    The length of each string are all smaller than 1001.
    The chars in first string are always different from each other.
    The chars in second string are always different from each other.
    There is no common char between first and second strings.
    The chars in third string are always in the first string or in the second string.
Output
    Print the minimum times YangShen must pressing the keys. 
Sample Input
abc def defabc
abc def abcdef
Sample Output
7
8
Hint
If you use SHIFT to input a char, the times of pressing SHIFT is always count by 1 whether you leave SHIFT up or not.
Source
Yan DONG