This page is still under construction.

Parts of this page are still being built. What you see may change.

Doublindromes

Time limit3sMemory limit512 MB

Summary
Count distinct substrings of s that are palindromes and split into two non-empty palindromes, with length at least k.
Level

Hard9 of 10

Topics
String, String matching, Hash map, Dynamic programming
Solved
No attempts yet

Problem

A string aa is a doublindrome if it is a palindrome and it can be represented as the concatenation of two non-empty palindromes bb and cc.

Given a string ss consisting of lowercase English letters, find the number of distinct substrings of ss that are doublindromes of length kk or more. Two substrings are considered distinct if they differ as strings.

Input

The first line contains one integer kk (2≤k≤1042 \le k \le 10^4). The second line contains the string ss consisting of lowercase English letters (k≤∣s∣≤104k \le |s| \le 10^4).

Output

Print one integer: the answer to the problem.

Examples1

  1. Example 1

    Input
    3
    xyxxyxxyx
    
    Expected output
    2