#pragma GCC optimization ("O3")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>,null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll M = 1e9 + 7;

int main()
{
    fast

    string s;
    deque<char> v;
    cin >> s;
    int c = 0;
    for(auto x : s)
    {
        if(x == 'R')c ^= 1;
        else
        {
            if(c == 1)v.push_front(x);
            else v.push_back(x);
        }
    }
    if(v.empty())return 0;
    if(c)reverse(v.begin(), v.end());
    vector<char> t;
    for(int i = 0; i < v.size(); i++)
    {
        int cnt = 0;
        char cc = v[i];
        while(i < v.size() && v[i] == cc)i++, cnt++;
        i--;
        if(cnt % 2)t.push_back(cc);
        while(t.size() > 1 && t.back() == t[t.size() - 2])t.pop_back(), t.pop_back();
    }

    for(auto x : t)cout << x;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<typename T>
void view_1d(vector<T> V, string sep) {
    for (ll i=0; i<V.size(); i++) {
        cout << V[i];
        if (i == V.size() - 1) {
            cout << endl;
        } else {
            cout << sep;
        }
    }
}

template<typename T>
void view_2d(vector<vector<T>> V, string sep) {
    for (ll i=0; i<V.size(); i++) {
        for (ll j=0; j<V[i].size(); j++) {
            cout << V[i][j];
            if (j == V[i].size() - 1) {
                cout << endl;
            } else {
                cout << sep;
            }
        }
    }
}

//==============================//


int main() {
    string S;
    cin >> S;

    int i = 0;
    int ans = 0;
    while (i < 12) {
        if (S.substr(i,4) == "ZONe") {
            i += 4;
            ans++;
        } else {
            i++;
        }
    }

    cout << ans << endl;
}
