#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const double EXP = 2.7182818284590452;
const double Pi = 3.1415926535;
const double EPS = 1e-9;
const int INF = 1000 * 1000 * 1001;
const long long INFL = (long long)INF * (long long)INF;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long extgcd(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x11, y11;
  long long d = extgcd(b % a, a, x11, y11);
  x = y11 - (b / a) * x11;
  y = x11;
  return d;
}
unsigned long long poww(unsigned long long v, unsigned long long p,
                        unsigned long long mod) {
  if (p == 0) return 1;
  if (p & 1) {
    return (poww(v, p - 1, mod) * v) % mod;
  } else {
    unsigned long long t = poww(v, p / 2, mod);
    return (t * t) % mod;
  }
}
const unsigned long long L31018 = 3000000000000000000L;
const unsigned long long L1018 = 1000000000000000000L;
int n;
string str;
int dx, dy;
long long res = 0;
bool Is(int l, int r) {
  dx = 0;
  dy = 0;
  for (int i = (l); i < (r); ++i) {
    if (str[i] == 'U') ++dy;
    if (str[i] == 'D') --dy;
    if (str[i] == 'L') --dx;
    if (str[i] == 'R') ++dx;
  }
  return dx == 0 && dy == 0;
}
void accept() {
  cin >> n;
  cin >> str;
  for (int i = (1); i < (n + 1); ++i) {
    for (int j = (0); j < (n - i + 1); ++j) res += Is(j, j + i);
  }
  cout << res;
}
const char inputFile[] = "busy_day.in";
int main(void) {
  accept();
  return 0;
}
