#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int n = (int)S.size();
  int fl = n - 1;
  while (fl >= 0 && S[fl] == '0') fl --;
  for (int i = 0; i <= fl; i ++) {
    int j = fl - i;
    if (S[i] != S[j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
#include<bits/stdc++.h>
using namespace std;
int n , f , las = -1e9;
string s;
int main()
{
	cin >> n >> s;
	if(s[0] != s[n - 1]) 
	{
		printf("1");
		return 0;
	}
	for(int i = 0 ; i < n ; i++ )
	{
		if(s[i] != s[0]) 
		{
			f |= (las == (i - 1)); 
			las = i;
		}
	}
	if(f) printf("2");
	else printf("-1");
	return 0;
}
/*
*/  