add kmp arithmetic