Calvin the robot lies in an infinite rectangular grid. Calvin's source code contains a list of n commands, each either 'U', 'R', 'D', or 'L' — instructions to move a single square up, right, down, or left, respectively. How many ways can Calvin execute a non-empty contiguous substrings of commands and return to the same square he starts in? Two substrings are considered different if they have different starting or ending indices.

Input

The first line of the input contains a single positive integer, n (1 ≤ n ≤ 200) — the number of commands.

The next line contains n characters, each either 'U', 'R', 'D', or 'L' — Calvin's source code.

Output

Print a single integer — the number of contiguous substrings that Calvin can execute and return to his starting square.

Examples

Input

6
URLLDR


Output

2


Input

4
DLUU


Output

0


Input

7
RLRLRLR


Output

12

Note

In the first case, the entire source code works, as well as the "RL" substring in the second and third characters.

Note that, in the third case, the substring "LR" appears three times, and is therefore counted three times to the total result.

import java.io.*;
import java.util.*;

//public class Main{		// codechef
public class Solution{	// codeforces	hackerrank

//public class MyTemplate {

	static FastScanner in;
	static PrintWriter out;

//	static HashMap<String, Pos> cmdSet = new HashMap<>();
//	static HashMap<String, Integer> cmdSet = new HashMap<>();

	// write code
	static void solve() {
		HashMap<String, Pos> cmdSet = new HashMap<>();
		int n = in.nextInt();
		String string = in.nextToken(), sub;
		int length = string.length();
		int count =0 ;
		
		cmdSet.put("", new Pos(0, 0));
//		Pos p;
		
		for( int c = 0 ; c < length ; c++ )
	      {
	         for(int i = 1 ; i <= length - c ; i++ )
	         {
	            sub = string.substring(c, c+i);
	            
	            int x=0, y=0;
//	            Pos p = new Pos(0,0) ;
				if(cmdSet.containsKey(sub)){
					Pos p=cmdSet.get(sub);
					if(0==p.x && 0==p.y){
						//System.out.println(sub);
						count++;
					}
		            cmdSet.put(sub, p);
				}else{
					Pos q=cmdSet.get(sub.substring(0, sub.length()-1));
					Pos p = new Pos(q.x, q.y);
					char k = sub.charAt(sub.length()-1);
					if('U' == k){
						p.y++;
					}else if('D' == k){
						p.y--;
					}else if('R' == k){
						p.x++;
					}else if('L' == k) {
						p.x--;
					}
					if(0==p.x && 0==p.y){
						//System.out.println(sub);
						count++;
					}
		            cmdSet.put(sub, p);
				}
				
	         }
	      }
		
		/*for (String s : cmdSet.keySet()) {
			System.out.println(s + " | " + cmdSet.get(s));
		}*/
		
		System.out.println(count);
		/*for (String s : cmdSet.keySet()) {
			System.out.println(s + " | " + cmdSet.get(s).x + ", " + cmdSet.get(s).y);
		}*/

	}
/*
	static HashMap<String, Pos> allSubCmds(char[] chs) {
		// HashSet<String> cmdSet = new HashSet<>();

		for (int i = 0; i != chs.length; i++) {
			char c = chs[i];
			HashMap<String, Pos> newSet = new HashMap<>();
			newSet.putAll(cmdSet);
			Set<String> keySet = cmdSet.keySet();
			for (String k : keySet) {
				Pos p = new Pos(i, i);
				if (k.length() > 0 ) {
					p = cmdSet.get(k);
					p.y = i;
				}
				newSet.put(k + c, p);
			}
			cmdSet = newSet;
		}

		return cmdSet;
	}
*/
	public static class Pos {
		int x;
		int y;

		Pos(int tX, int tY) {
			this.x = tX;
			this.y = tY;
		}

	}

	// part of pre-defined template
	public static void run() {
		in = new FastScanner();
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		solve();
		out.close();
	}

	public static void main(String[] args) {
		run();
	}

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
