Rikka with New Year's Party

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

문제

Rikka is now organizing a new year's party for the algorithm association. She has invited nn actors from 2626 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 s_is\_i-th group. Rikka decides to choose a non-empty range \[l,r] (1lrn)\[l,r]\ (1 \leq l \leq r \leq n) and lets all actors in this range join in the opening show.

Rikka has prepared 2626 different actions. Suppose the range \[l,r]\[l,r] has been determined, the opening show will proceed in the following way:

  • The actors will play in order. The ll-th actor will play at first and the rr-th will play at last;
  • Suppose now the ii-th player is going to play. He/she will decide his/her action in the following way: If there is a player jj which plays before him/her and is also from group s_is\_i, the ii-th player will choose the same action as the player jj. Otherwise, he/she will choose the first action (the action with the smallest index) which has not been chosen by anyone before.

For example, if 55 players from groups "abacb" are selected, they will chose actions 1,2,1,3,21,2,1,3,2 respectively. 

Rikka finds that different ranges may sometimes result in the same show. For example, if there are 66 players and they are from "abacbc" respectively, range \[1,3]\[1,3] and \[4,6]\[4,6] will result in the same show.

Given string ss, Rikka wants you to calculate the number of different possible shows.

  • Two shows are different if and only if they contain different numbers of actions or there exists an index ii such that the ii-th actions of these two shows are different;
  • A show is possible if and only if it can be produced by some range \[l,r]\[l,r] of ss.

입력

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

The second line contains a lowercase string ss of length nn. s_is\_i represents the group of the ii-th actor.

출력

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

힌트

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

  1. Action 11, corresponding to range \[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 range \[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 range \[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].