#include <bits/stdc++.h>

using namespace std;

int main()
{
    string n;
    getline (cin,n);
    int s=0;

    for (int i=0;i<(int) n.length();i++)
    {
        s+=((int) n[i]-'0');
    }
    if (s<3)
    {
        cout<<-1;
        goto here;
    }
    else if (s%3==0)
    {
        cout<<0;
        goto here;
    }
    else if (s%3==1)
    {
        int l=0, m=0;
        for (int i=0;i<(int)n.length();i++)
        {
            if (((int)n[i]-'0')%3==1 )
            {
                l++;
            }
            else if (((int)n[i]-'0')%3==2 )
            {
                m++;
            }

        }

        if (((l>=1)&&(int)n.length()>1) || ((m>=2 ) && (n.length()>2)))
            {
                cout<< ((l>=1) ? (1) :(2));
                goto here;
            }
            else
            {
                cout<<-1;
                goto here;
            }


    }
    else if (s%3==2)
    {
        int l=0, m=0;
        for (int i=0;i<(int)n.length();i++)
        {
            if (((int)n[i]-'0')%3==2 )
            {
                m++;
            }
            else if (((int)n[i]-'0')%3==1 )
            {
                l++;
            }

        }

        if (((m>=1)&&(int)n.length()>1) || ((l>=2 ) && (n.length()>2)))
            {
                cout<< ((m>=1) ? (1) :(2));
                goto here;
            }
            else
            {
                cout<<-1;
                goto here;
            }


    }

    here:;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  string N;
  cin >> N;
  int length;
  int count=0;
  length = N.size();
  int x=0;
  for (int i=0;i<length-1;i++) {
    if(N.at(length-1-i)=='0'){
      count++;
    }else{
      break;
    }
  }
  for (int i=0;i<1+(length-count)/2;i++){
    if(N.at(i)!=N.at(length-count-1-i)){
      x++;
      break;
    }
  }
  if(x==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}