#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define drep(i,b,a) for(int i = (b)-1; i >= (a); i--)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(v) sort(v.begin(),v.end());
#define RSORT(v) sort(v.rbegin(),v.rend());
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
const int inf = 1 << 30; const ll infl = 1LL << 60; const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool  odd(T x) { return x & 1; }
template<class T> inline bool even(T x) { return !(x & 1); }
template<typename A, size_t N, typename T> 
void Fill(A (&array)[N], const T &val) {
    std::fill( (T*)array, (T*)(array+N), val );
}
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << endl; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }
//----------------------------------------------------------------------------------------------


int main() 
{
    ll n;
    cin >> n;
    __int128_t l = 0, r = 4000000000;
    while(r-l>1) {
        __int128_t mid = (l+r)/2;
        if(mid*(mid+1)/2 <= (__int128_t)(n+1)) l = mid;
        else r = mid;
    }
    cout << (ll)(n - l + 1) << endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;
const long LINF = 1L << 62;
const int IINF = 1 << 30;
#define rep(i, s, n) for (long i = s; i < (long)(n); i++)
template <class T>
using Graph = std::vector<std::vector<T>>;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
bool is_in(int x, int y, int xlim, int ylim)
{
    return (x >= 0 && x < xlim && y >= 0 && y < ylim);
}
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
using ll = long;
constexpr ll MOD = 1000000007;

int main()
{
    std::deque<char> deq;
    string s;
    cin >> s;
    bool pos = true;
    for (ll i = 0; i < s.size(); i++) {
        char c = s[i];
        if (c == 'R') {
            pos = !pos;
        } else {
            if (pos) {
                deq.push_back(c);
            } else {
                deq.push_front(c);
            }
        }
    }
    if (!pos) {
        reverse(deq.begin(), deq.end());
    }
    std::string ans;
    for (char& c : deq) {
        if (ans.size() > 0 && ans.back() == c) {
            ans.pop_back();
        } else {
            ans.push_back(c);
        }
    }
    cout << ans << endl;
}
