match string count based on kmp