Border

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You are given a string S\[1n]S\[1 \ldots n]. We denote its substrings as S\[lr]S\[l \ldots r], and when l>rl > r, such substring is defined to be an empty string. Let f(i, j) = \max \left\\{k\~|\~0 \leq k \leq j-i,\~S\[i \ldots i+k-1] = S\[j-k+1 \ldots j]\right\\} \text{.}

Output _1i<jnf(i,j)\sum\limits\_{1 \leq i < j \leq n} f(i, j).

The string SS is generated in the following way. The values nn and seed\mathit{seed} are the parameters of the generator.

long long seed;
for (int i = 1; i <= n; i++) {
    seed = (seed * 13331 + 23333) % 1000000007;
    s[i] = 'a' + (seed & 1);
}

입력

The first line contains two integers: nn and seed\mathit{seed} (1n1061 \leq n \leq 10^6, 0seed109+60 \leq \mathit{seed} \leq 10^9 + 6).

출력

Output the answer.