#include <bits/stdc++.h>
using namespace std;
long long n, j, i, l, t, k, x, y;
string s, a[10000001];
int main() {
  cin >> n >> s;
  for (i = 1; i < n; i++)
    for (j = 0; j < n - i; j++) {
      t++;
      for (l = 0; l <= i; l++) {
        a[t] += s[j + l];
      }
    }
  for (i = 1; i <= t; i++) {
    x = 0;
    y = 0;
    for (j = 0; j < a[i].size(); j++)
      if (a[i][j] == 'U')
        y++;
      else if (a[i][j] == 'D')
        y--;
      else if (a[i][j] == 'L')
        x--;
      else if (a[i][j] == 'R')
        x++;
    if (x == 0 && y == 0) k++;
  }
  cout << k;
  return 0;
}
