#include <bits/stdc++.h>
using namespace std;
int l;
char s[205];
int exe(int a, int b) {
  int u = 0, r = 0;
  for (int i = a; i < b; i++) {
    switch (s[i]) {
      case 'U':
        u++;
        break;
      case 'D':
        u--;
        break;
      case 'R':
        r++;
        break;
      case 'L':
        r--;
        break;
    }
  }
  return u == 0 and r == 0;
}
int main() {
  scanf("%d\n", &l);
  gets(s);
  int r = 0;
  for (int i = 0; i < l; i++)
    for (int j = i + 1; j <= l; j++) r += exe(i, j);
  printf("%d", r);
}
