#include <bits/stdc++.h>
using namespace std;
const long long max_n = 1e5 + 20;
long long n, m, mn = 1e9 + 20, tmp1, tmp2, cnt;
long long a[max_n], b[max_n], c[max_n];
string s;
long long alert, v, mark[max_n], e[max_n];
double ans;
bool check(long long x, long long y) {
  long long l = 0, u = 0;
  for (long long i = x; i < y; i++) {
    if (s[i] == 'L')
      l++;
    else if (s[i] == 'U')
      u++;
    else if (s[i] == 'R')
      l--;
    else
      u--;
  }
  return u == l && !u;
}
int32_t main() {
  cin >> n;
  cin >> s;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      ans += check(i, j + 1);
    }
  }
  cout << ans;
  return 0;
}
