#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  string s;
  char stringtemporary[n];
  scanf("%s", stringtemporary);
  s = stringtemporary;
  string tmp;
  int u, d, r, l, hasil(0);
  for (int i = 0; i < (n); ++i) {
    for (int j = (i + 2); j <= (n); ++j) {
      u = 0;
      d = 0;
      l = 0;
      r = 0;
      tmp = s.substr(i, j - i);
      for (int k = 0; k < (j - i); ++k) {
        if (tmp[k] == 'L')
          l++;
        else if (tmp[k] == 'R')
          r++;
        else if (tmp[k] == 'D')
          d++;
        else if (tmp[k] == 'U')
          u++;
      }
      if ((u == d) && (r == l)) hasil++;
      j++;
    }
  }
  printf("%d", hasil);
  printf("\n");
}
