import std.stdio;

void main()
{
	int n;
	int res = 0;
	char[200 + 1] s;
	
	scanf("%d%s", &n, &s[0]);
	for (int i = 0; i < n; i++) {
		int vertical = 0;
		int horizontal = 0;
		for (int j = i; j < n; j++) {
			if (s[j] == 'U')
				vertical--;
			if (s[j] == 'D')
				vertical++;
			if (s[j] == 'L')
				horizontal--;
			if (s[j] == 'R')
				horizontal++;
			
			if (vertical == 0 && horizontal == 0)
				res++;
		}
	}
	
	printf("%d\n", res);
}
