#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 100000 + 5;
int main() {
  long long n, i, sum, ii, j, jj;
  char s[205];
  while (~scanf("%lld", &n)) {
    s[0] = '!';
    scanf("%s", s + 1);
    sum = 0;
    for (i = 1; i <= n; i++) {
      ii = jj = 0;
      for (j = i; j <= n; j++) {
        if (s[j] == 'U')
          jj--;
        else if (s[j] == 'D')
          jj++;
        else if (s[j] == 'R')
          ii++;
        else
          ii--;
        if (!ii && !jj) sum++;
      }
    }
    printf("%lld\n", sum);
  }
  return 0;
}
