The string t_1t_2 ... t_k is good if each letter of this string belongs to at least one palindrome of length greater than 1.

A palindrome is a string that reads the same backward as forward. For example, the strings A, BAB, ABBA, BAABBBAAB are palindromes, but the strings AB, ABBBAA, BBBA are not.

Here are some examples of good strings: 

  * t = AABBB (letters t_1, t_2 belong to palindrome t_1 ... t_2 and letters t_3, t_4, t_5 belong to palindrome t_3 ... t_5); 
  * t = ABAA (letters t_1, t_2, t_3 belong to palindrome t_1 ... t_3 and letter t_4 belongs to palindrome t_3 ... t_4); 
  * t = AAAAA (all letters belong to palindrome t_1 ... t_5); 



You are given a string s of length n, consisting of only letters A and B.

You have to calculate the number of good substrings of string s.

Input

The first line contains one integer n (1 ≤ n ≤ 3 ⋅ 10^5) — the length of the string s.

The second line contains the string s, consisting of letters A and B.

Output

Print one integer — the number of good substrings of string s.

Examples

Input


5
AABBB


Output


6


Input


3
AAA


Output


3


Input


7
AAABABB


Output


15

Note

In the first test case there are six good substrings: s_1 ... s_2, s_1 ... s_4, s_1 ... s_5, s_3 ... s_4, s_3 ... s_5 and s_4 ... s_5.

In the second test case there are three good substrings: s_1 ... s_2, s_1 ... s_3 and s_2 ... s_3.
import java.util.Scanner;

/**
 * 通过题意分析，可知bad substring的模式是：连续相同字符的子串，在头尾任意一边接上另一个子串
 * 例如：
 * ABBB...BBB
 * BAAA...AAA
 * AAA...AAAB
 * BBB...BBBA
 * 其他的字符串形式都满足good substring
 * 因此，问题可转化为：总的子串数 - bad子串数
 *
 * 设：
 * n：字符串总长度
 * l：左边连续的字符串数
 * r：右边连续的字符串数
 * c：字符串中出现的不连续次数，即：AB和BA的次数
 * bad：bad子串数
 * good：good子串数
 * total：总的子串数
 *
 * 观察某个AB或BA对，以此为中心，分别向左边和右边延展可分别得若干bad子串，两边相加再减1（中心重复），可得该中心的所有bad子串数
 * 把所有AB、BA按上述方式计算之后再求和，可得所有bad子串数，合并简化后可得：
 * bad = n * 2 - (l + r) - c
 *
 * 而：
 * total = n * (n - 1) / 2
 *
 * 所以：
 * good = total - bad
 *
 */


public class CF1238D {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        String s = sc.next();

        if(n == 1){
            System.out.println(0);
        }else{
            char[] s_c = s.toCharArray();
            long l = n, r = n, c = 0;

            for(int i = 0; i < s_c.length - 1; i++){
                if(s_c[i] != s_c[i + 1]){
                    c++;
                    if(l == n){
                        l = i + 1;
                    }
                    r = s_c.length - i - 1;
                }
            }

            long bad = n * 2 - (l + r) - c;
            long total = n * (n - 1) / 2;
            long good = total - bad;
            System.out.println(good);
        }
    }
}
