#include <bits/stdc++.h>
using namespace std;
string s;
int l, high, len, ans;
int main() {
  cin >> l;
  cin >> s;
  for (int i = 0; i < l; i++)
    for (int j = i; j < l; j++) {
      string w;
      high = len = 0;
      for (int k = i; k <= j; k++) {
        w += s[k];
      }
      for (int a = 0; a < w.length(); a++) {
        if (w[a] == 'U') high++;
        if (w[a] == 'D') high--;
        if (w[a] == 'L') len--;
        if (w[a] == 'R') len++;
      }
      if (!high && !len && w.length() >= 1) ans++;
    }
  cout << ans;
  return 0;
}
