#include <bits/stdc++.h>
using namespace std;
char commands[210];
int main() {
  int n;
  cin >> n;
  int x = 0;
  int y = 0;
  int out = 0;
  for (int i = 0; i < n; i++) {
    cin >> commands[i];
  }
  for (int i = 2; i <= n; i++) {
    for (int k = 0; k <= n - i; k++) {
      for (int j = k; j < i + k; j++) {
        if (commands[j] == 'U')
          y++;
        else if (commands[j] == 'D')
          y--;
        else if (commands[j] == 'L')
          x--;
        else if (commands[j] == 'R')
          x++;
      }
      if (x == 0 && y == 0) {
        out++;
      }
      x = 0;
      y = 0;
    }
  }
  cout << out << endl;
}
