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.awt.*;
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main implements Runnable {
     
    int maxn = (int)2e3+100;
    int mod = (int)1e9+7;
    int inf = (int)1e9;
    int n,m,k;
    int[] a = new int[maxn];
    int used[][] = new int[maxn][maxn];
    
    void solve() throws Exception {
    	n = in.nextInt();
    	String s = in.nextToken();
    	int x = 1000; 
    	int y = 1000;
    	int cnt = 0;
    	used[x][y] = 1;
    	for (int i=0; i<s.length(); i++) {
    		if (s.charAt(i)=='U') {
    			x--;
    		} else if (s.charAt(i)=='D') {
    			x++;
    		} else if (s.charAt(i)=='L') {
    			y--;
    		} else if (s.charAt(i)=='R') {
    			y++;
    		}
    		cnt+=used[x][y];
    		used[x][y]++;
    	}
    	
    	out.println(cnt);
    }
    
	class Pair implements Comparable<Pair>{
        int x,y; 
        public Pair (int x, int y) {
            this.x = x;
            this.y = y;
        }
 
        @Override
        public int compareTo(Pair p) {
            if (x>p.x) return 1;
            else if (x==p.x) {
                if (y>p.y) return 1;
                else if (y==p.y) return 0;
                else return -1;
            } else {
                return -1;
            }
         
        }
    }
     
    String fileInName = "network";
    boolean file = false;
    boolean isAcmp = true;
     
    static Throwable throwable;
    public static void main (String [] args) throws Throwable {
    	Locale.setDefault(new Locale("en", "US"));
        Thread thread = new Thread(null, new Main(), "", (1 << 26));
        thread.start();
        thread.join();
        thread.run();
        if (throwable != null)
            throw throwable;
    }
     
    FastReader in;
    PrintWriter out;
 
    public void run() {
        String fileIn = "input.txt";
        String fileOut = "output.txt";
         
        try {
            if (isAcmp) {
                if (file) {
                    in = new FastReader(new BufferedReader(new FileReader(fileIn)));
                    out = new PrintWriter (fileOut);
                } else {
                    in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                    out = new PrintWriter(System.out);
                }
            } else if (file) {
                in = new FastReader(new BufferedReader(new FileReader(fileInName+".in")));
                out = new PrintWriter (fileInName + ".out");
            } else {
                in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(System.out);
            }
             
            solve();
        } catch(Exception e) {
            throwable = e;
        } finally {
            out.close();
        }
 
    }
}
 
class FastReader {
    BufferedReader bf;
    StringTokenizer tk = null;
 
    public FastReader(BufferedReader bf) {
        this.bf = bf;
    }
     
    public String nextToken () throws Exception {
        if (tk==null || !tk.hasMoreTokens()) {
            tk = new StringTokenizer(bf.readLine());
        }
        if (!tk.hasMoreTokens()) return nextToken();
        else
            return tk.nextToken();
    }
     
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }
     
    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }
     
    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}