#include <bits/stdc++.h>
using namespace std;
int vex[300], sta[300];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char op;
    scanf(" %c", &op);
    if (op == 'U')
      sta[i] = 1;
    else if (op == 'D')
      sta[i] = -1;
    else if (op == 'R')
      vex[i] = 1;
    else if (op == 'L')
      vex[i] = -1;
  }
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    int nowl = 0, nowu = 0;
    for (int j = i; j <= n; j++) {
      nowl += vex[j];
      nowu += sta[j];
      if (nowl == 0 && nowu == 0) sum++;
    }
  }
  printf("%I64d\n", sum);
  return 0;
}
