#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9) + 2;
int B[201][201] = {0};
int C[201][201] = {0};
int main() {
  char a[201];
  int n = 0;
  fscanf(stdin, "%d", &n);
  fscanf(stdin, "%s", a);
  int s1 = 0, s2 = 0, res = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'L')
      s1++;
    else if (a[i] == 'R')
      s1--;
    else if (a[i] == 'U')
      s2++;
    else if (a[i] == 'D')
      s2--;
    B[0][i] = s1;
    C[0][i] = s2;
    if ((s1 == 0) && (s2 == 0)) res++;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if ((B[0][j] == B[0][i]) && (C[0][j] == C[0][i])) res++;
    }
  }
  cout << res;
  return 0;
}
