#include <bits/stdc++.h>
using namespace std;
complex<int> pre[205];
int main() {
  int n;
  char str[205];
  pre[0] = complex<int>(0, 0);
  cin >> n >> (str + 1);
  for (int i = 1; i <= n; i++) {
    complex<int> move;
    if (str[i] == 'L') move = complex<int>(-1, 0);
    if (str[i] == 'R') move = complex<int>(1, 0);
    if (str[i] == 'U') move = complex<int>(0, 1);
    if (str[i] == 'D') move = complex<int>(0, -1);
    pre[i] = pre[i - 1] + move;
  }
  long long int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (pre[j] - pre[i] == complex<int>(0, 0)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
