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.
// $_Hardik_Dobariya

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;


public class Main {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;
	private PrintWriter pw;
	private long mod = 1000000000 + 7;

	private StringBuilder ans_sb;
	private void soln() {
//		int t = nextInt();
//		while(t-- > 0) {
//			int h = nextInt();
//			int n = nextInt();
//			int[] ps = nextIntArray(n);
//			ArrayList<Range> ranges = new ArrayList<>();
//			int st = -1;
//			int et = -1;
//			for(int i=0; i<n; i++) {
//				int cur = ps[i];
//				if(cur != et - 1) {
//					if(st != -1)
//						ranges.add(new Range(st ,et));
//					st = cur;
//					et = cur;
//				}else {
//					et = cur;
//				}
//			}
//			ranges.add(new Range(st ,et));
//			//debug(ranges);
//			int cnt = 0;
//			for(Range r: ranges) {
//				int l = r.l;
//				int ri = r.r;
//				int diff = ri-l+1;
//				if(diff%2 == 0 && l==h && ri != 1) {
//					cnt++;
//				}
//				if(diff%2 != 0 && ri!=1 && l != h) {
//					cnt++;
//				}
//			}
//			pw.println(cnt);
//		}
		long n = nextInt();
		String s = nextLine();
		ArrayList<Integer> list = new ArrayList<>();
		char prev = 'a';
		int cnt = 1;
		for(int i=0;i<n;i++) {
			char c = s.charAt(i);
			if(c == prev) {
				cnt++;
			}else if(prev != 'a'){
				list.add(cnt);
				cnt = 1;
			}
			prev = c;
		}
		list.add(cnt);
		long tot = (n*(n-1))/2;
		n = list.size();
		for(int i=0;i<n-1;i++) {
			long right = list.get(i+1);
			long cur = list.get(i);
			tot -= (right+cur-1);
		}
		pw.println(tot);
	}
	private class Range{
		int l, r;
		public Range(int a, int b) {
			l = a;
			r = b;
		}
		public String toString() {
			return "[ "+l+" "+r+" ]";
		}
	}
		
	private long gcd(long n, long l) {
		if (l == 0)
			return n;
		return gcd(l, n % l);
	}
	
	private static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
	
	private long pow(long a, long b, long c) {
		if (b == 0)
			return 1;
		long p = pow(a, b / 2, c);
		p = (p * p) % c;
		return (b % 2 == 0) ? p : (a * p) % c;
	}
	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				new Main().solve();
			}
		}, "1", 1 << 26).start();
		//new Main().solve();
	}

	public StringBuilder solve() {
		InputReader(System.in);
		/*
		 * try { InputReader(new FileInputStream("C:\\Users\\hardik\\Desktop\\in.txt"));
		 * } catch(FileNotFoundException e) {}
		 */
		pw = new PrintWriter(System.out);
		// ans_sb = new StringBuilder();
		soln();

		pw.close();
		// System.out.println(ans_sb);
		return ans_sb;
	}

	public void InputReader(InputStream stream1) {
		stream = stream1;
	}

	private boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	private boolean isEndOfLine(int c) {
		return c == '\n' || c == '\r' || c == -1;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	private int nextInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private long nextLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private String nextToken() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	private String nextLine() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isEndOfLine(c));
		return res.toString();
	}

	private int[] nextIntArray(int n) {
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextInt();
		}
		return arr;
	}

	private long[] nextLongArray(int n) {
		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nextLong();
		}
		return arr;
	}

	private void pArray(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private void pArray(long[] arr) {
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
		return;
	}

	private boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return isWhitespace(c);
	}

	private char nextChar() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		char c1 = (char) c;
		while (!isSpaceChar(c))
			c = read();
		return c1;
	}

	private interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}