#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int mof = 1000000007;
const int inf = 1000000010;
const long long llinf = 1000000007000000007;
const double pi = 3.14159265359;
const int maxn = 111111;
string second;
int n;
bool ok(string lol) {
  int a = 0, b = 0, c = 0, d = 0;
  for (int i = 0; i < lol.length(); i++) {
    if (lol[i] == 'L') a++;
    if (lol[i] == 'R') b++;
    if (lol[i] == 'D') c++;
    if (lol[i] == 'U') d++;
  }
  if (a == b && c == d) return true;
  return false;
}
int main() {
  cin >> n;
  cin >> second;
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string lol = "";
      for (int k = i; k <= j; k++) {
        lol += second[k];
      }
      if (ok(lol)) res++;
    }
  }
  cout << res << endl;
  return 0;
}
