kmp for period