#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int l = 0, r = 0, u = 0, d = 0;
      for (int k = i; k <= j; k++) {
        if (s[k] == 'L')
          l++;
        else if (s[k] == 'R')
          r++;
        else if (s[k] == 'U')
          u++;
        else if (s[k] == 'D')
          d++;
      }
      if (r == l && u == d) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
