#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int sum1 = 0;
  int sum2 = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    string temp = "";
    for (int j = i; j < s.size(); j++) {
      temp += s[j];
      sum1 = 0;
      sum2 = 0;
      for (int k = 0; k < temp.size(); k++) {
        if (temp[k] == 'U') {
          sum1++;
        }
        if (temp[k] == 'D') {
          sum1--;
        }
        if (temp[k] == 'L') {
          sum2++;
        }
        if (temp[k] == 'R') {
          sum2--;
        }
      }
      if (sum1 == 0 && sum2 == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
