Under construction

Still being built. Things may change

Rikka with New Year's Party

Time limit5sMemory limit512 MB

Level

Not classified yet

Solved
No attempts yet

Problem

Rikka is now organizing a new year's party for the algorithm association. She has invited nn actors from 26 different groups, represented by lowercase letters. Rikka wants to select some actors among them for the opening show.

Now, the nn actors are in a row. The ii-th actor is from the sis_i-th group. Rikka decides to choose a non-empty range [l,r][l,r] (1≤l≤r≤n1 \leq l \leq r \leq n) and lets all actors in this range join the opening show.

The show proceeds as follows.

  • The actors play in order. The ll-th actor plays first, and the rr-th actor plays last.
  • When the ii-th actor is about to play, they decide their action as follows. If an actor jj who played before them is from the same group sis_i, the ii-th actor chooses the same action as actor jj. Otherwise, they choose the action with the smallest index that no one has chosen before.

For example, if the 5 actors are from groups abacb, they choose actions 1,2,1,3,21,2,1,3,2 in that order.

Rikka found that different ranges can produce the same show. For example, if there are 6 actors from groups abacbc, the ranges [1,3][1,3] and [4,6][4,6] produce the same show.

Two shows are different if they have different numbers of actions, or if some index ii has different ii-th actions. A show is possible if some range [l,r][l,r] of ss produces it. Given ss, count the number of different possible shows.

Input

The first line contains a single integer nn (1≤n≤1051 \leq n \leq 10^5), the number of actors.

The second line contains a lowercase string ss of length nn. sis_i is the group of the ii-th actor.

Output

Output a single integer on one line, the number of different possible shows.

Hint

For the first sample, there are 7 different possible shows:

  1. Action 11, corresponding to ranges [1,1][1,1], [2,2][2,2], [3,3][3,3], [4,4][4,4], [5,5][5,5].
  2. Actions 1,21,2, corresponding to ranges [1,2][1,2], [2,3][2,3], [3,4][3,4], [4,5][4,5].
  3. Actions 1,2,11,2,1, corresponding to ranges [1,3][1,3], [2,4][2,4].
  4. Actions 1,2,31,2,3, corresponding to range [3,5][3,5].
  5. Actions 1,2,1,21,2,1,2, corresponding to range [1,4][1,4].
  6. Actions 1,2,1,31,2,1,3, corresponding to range [2,5][2,5].
  7. Actions 1,2,1,2,31,2,1,2,3, corresponding to range [1,5][1,5].

Examples3

  1. Example 1

    Input
    5
    ababc
    
    Expected output
    7
    
  2. Example 2

    Input
    6
    abacbc
    
    Expected output
    10
    
  3. Example 3

    Input
    11
    ababcdcefef
    
    Expected output
    33