#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char str[300];
  cin >> n;
  cin >> str;
  int i, j, p = 0, q = 0;
  long long int ans = 0;
  for (i = 0; i < n; i++) {
    p = 0;
    q = 0;
    for (j = i; j < n; j++) {
      if (str[j] == 'R')
        p = p + 1;
      else if (str[j] == 'L')
        p = p - 1;
      else if (str[j] == 'D')
        q = q - 1;
      else
        q = q + 1;
      if (p == 0 && q == 0) ans++;
    }
  }
  cout << ans;
}
