#include <bits/stdc++.h>
using namespace std;
string s;
int n, ans, x = 201, y = 201, u[405][405];
int main() {
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < n; ++i) {
    ans += u[x][y];
    ++u[x][y];
    if (s[i] == 'U') ++x;
    if (s[i] == 'D') --x;
    if (s[i] == 'R') ++y;
    if (s[i] == 'L') --y;
  }
  ans += u[x][y];
  cout << ans;
  return 0;
}
