#include <bits/stdc++.h>
using namespace std;
int n, x, y, c, ans;
string s;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++) {
    for (int j = i; j < s.length(); j++) {
      if (s[j] == 'U')
        y++;
      else if (s[j] == 'D')
        y--;
      else if (s[j] == 'R')
        x++;
      else if (s[j] == 'L')
        x--;
      if (x == 0 && y == 0) c++;
    }
    ans += c;
    c = 0;
    x = 0;
    y = 0;
  }
  cout << ans << endl;
}
