#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
using ll = long long;
//<< fixed << setprecision(n) 小数第n位まで表示

int main() {
    int N;
    cin >> N;
    cout << N - 1 << endl;
    return 0;
}
#include<bits/stdc++.h>
using namespace std;

#define LL long long

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    string s, t = ""; cin >> s; bool ok = 1;

    deque<char> q;
    for(char c : s) {
        if(c == 'R') ok = 1 - ok;
        else {
            if(ok) {
                if(q.size() && q.back() == c) {
                    q.pop_back();
                    continue;
                }
                q.push_back(c);
            }
            else {
                if(q.size() && q.front() == c) {
                    q.pop_front();
                    continue;
                }
                q.push_front(c);
            }
        }
    }

    for(char c : q) t += c;
    if(!ok) reverse(t.begin(), t.end());
    cout << t << '\n';
}