#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int dp[105][105][105];
int rec(int ind, int x, int y) {
  int &ret = dp[ind][x][y];
  if (ind == n) {
    if (x == 0 && y == 0) return 0;
    return -1e9;
  }
  if (~ret) return ret;
  ret = -1e9;
  if (s[ind] == 'L' || s[ind] == 'R') {
    ret = 1 + rec(ind + 1, (s[ind] == 'L' ? -1 : 1) + x, y);
  } else {
    ret = max(ret, 1 + rec(ind + 1, x, (s[ind] == 'U' ? 1 : -1) + y));
  }
  ret = max(ret, rec(ind + 1, x, y));
  return ret;
}
int main() {
  while (cin >> n >> s) {
    memset(dp, -1, sizeof dp);
    cout << rec(0, 0, 0) << endl;
  }
  return 0;
}
