#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int n;
string s;
int vis[410][410];
int main(int argc, char *argv[]) {
  cin >> n;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    for (int j = i + 1; j < s.length(); j++) {
      int x = 200, y = 200;
      memset(vis, 0, sizeof(vis));
      vis[x][y] = 1;
      for (int k = i; k <= j; k++) {
        if (s[k] == 'U') x--;
        if (s[k] == 'D') x++;
        if (s[k] == 'R') y++;
        if (s[k] == 'L') y--;
      }
      if (vis[x][y] == 1) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
