#include <bits/stdc++.h>
using namespace std;
const int N = (int)500;
const int b = 220;
int n, c[N][N];
string s;
int x, y;
int main() {
  x = y = b;
  c[x][y] = 1;
  cin >> n >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    if (s[i] == 'R') x++;
    if (s[i] == 'L') x--;
    c[x][y]++;
  }
  long long ans = 0LL;
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j) ans += 1LL * c[i][j] * (c[i][j] - 1LL) / 2LL;
  cout << ans << endl;
  return 0;
}
