#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const long long mod = 1e9 + 7;
int dir[4][2] = {0, 1, 0, -1, 1, 0, -1, 0};
char s[205];
int main() {
  int n;
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int x = 0, y = 0;
    for (int j = i; j < n; j++) {
      if (s[j] == 'U')
        x += dir[0][0], y += dir[0][1];
      else if (s[j] == 'D')
        x += dir[1][0], y += dir[1][1];
      else if (s[j] == 'L')
        x += dir[2][0], y += dir[2][1];
      else
        x += dir[3][0], y += dir[3][1];
      if (!x && !y) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
