#include <bits/stdc++.h>
const double EPS = 1e-7, PI = acos(-1.0);
using namespace std;
const int NUM = 210;
int n;
char cmd[NUM];
int main() {
  while (~scanf("%d%s", &n, cmd)) {
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i; j < n; ++j) {
        int left = 0, up = 0;
        for (int k = i; k <= j; ++k) {
          if (cmd[k] == 'U')
            ++up;
          else if (cmd[k] == 'R')
            --left;
          else if (cmd[k] == 'D')
            --up;
          else
            ++left;
        }
        if (left == 0 && up == 0) ++ans;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
