#include <bits/stdc++.h>
using namespace std;
char arr[209];
int main() {
  int n, x, y, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      x = 0, y = 0;
      for (int g = i; g <= j; g++) {
        if (arr[g] == 'U') x--;
        if (arr[g] == 'D') x++;
        if (arr[g] == 'L') y--;
        if (arr[g] == 'R') y++;
      }
      if (x == 0 && y == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
