#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int i, j, ans = 0;
  for (i = 0; i < n; i++) {
    int top = 0, right = 0;
    for (j = i; j < n; j++) {
      if (s[j] == 'U')
        top++;
      else if (s[j] == 'D')
        top--;
      else if (s[j] == 'R')
        right++;
      else
        right--;
      if (top == 0 && right == 0) ans++;
    }
  }
  cout << ans;
  return 0;
}
