#arc130a. [arc130_a]Remove One Character

[arc130_a]Remove One Character

Problem Statement

You are given a string SS of length NN. For each 1leqileqN1\\leq i\\leq N, let SiS_i denote the string obtained by deleting the ii-th character from SS.

Find the number of pairs of integers (i,j)(i,j) that satisfy both of the conditions below.

  • 1leqi<jleqN1\\leq i < j\\leq N
  • Si=SjS_i = S_j

Constraints

  • 2leqNleq3times1052\\leq N\\leq 3\\times 10^5
  • SS is a string of length NN consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

NN SS

Output

Print the answer.


Sample Input 1

7
abbbcca

Sample Output 1

4

Here are the strings SiS_i in order: bbbcca, abbcca, abbcca, abbcca, abbbca, abbbca, abbbcc.

The following 44 pairs (i,j)(i,j) satisfy the conditions.

  • (i,j)=(2,3)(i,j) = (2,3)
  • (i,j)=(2,4)(i,j) = (2,4)
  • (i,j)=(3,4)(i,j) = (3,4)
  • (i,j)=(5,6)(i,j) = (5,6)

Sample Input 2

4
xxxx

Sample Output 2

6

Sample Input 3

2
pp

Sample Output 3

1

Sample Input 4

2
st

Sample Output 4

0