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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    string S; cin >> S;

    int N = S.size();
    if(N<3){
        int a = 0;
        REP(i,N){
            a *= 10;
            a += S[N-1-i]-'0';
        }
        if(a%8 == 0){
            cout << "Yes" << en;
            return;
        }
        REVERSE(S);
        a = 0;
        REP(i,N){
            a *= 10;
            a += S[N-1-i]-'0';
        }
        if(a%8 == 0) cout << "Yes" << en;
        else cout << "No" << en;
        return;
    }

    VI n(10,0);
    for(char c : S){
        int x = c-'0';
        n[x]++;
    }

    int x = 104;
    while(x<1000){
        VI m(10,0);
        int y = x;
        REP(i,3){
            m[y%10]++;
            y /= 10;
        }

        bool flag = true;
        REP(i,10){
            if(m[i]>n[i]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes" << en;
            return;
        }
        x += 8;
    }
    cout << "No" << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int SINF = 1LL << 29;
const ll mod = 1000000000+7;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }

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

    deque<char> deq;
    bool rev = false;

    rep(i, s.size()) {
        if(s[i] == 'R') rev = !rev;
        else if(rev) {
            deq.push_front(s[i]);
        }
        else {
            deq.push_back(s[i]);
        }
    }
    string ans;
    for(auto tmp:deq) ans.push_back(tmp);
    if(rev) reverse(all(ans));
    string res = "";
    rep(i, ans.size()) {
        res.push_back(ans[i]);
        if(res.size() >= 2) {
            string a = res.substr(res.size()-2, 2);
            if(a[0] == a[1]) res.erase(res.size()-2, 2);
        }
    }
    cout << res << endl;
}