#include <bits/stdc++.h>
#define fi first
#define se second 
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define eps 1e-18
#define pi acos(-1)
#define ar array
#define int int64_t

using namespace std;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.fi << ", " << p.se << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
template<typename T> istream& operator>>(istream &cin, vector<T> &v){
  for(int i=0;i<v.size()-1;++i)cin>>v[i];
  return cin>>v[(int)v.size()-1];
}

template<class T>
T roof(T a, T b){
  return (a+b-1)/b;
}
template<class T>
T modulo(T a, T m){
  return (a%m+m)%m;
}

int Log(int a, int b){
  int c=0;
  while(a)a/=b,c++;
  return c;
}

int qpow(int x,int n, int m){
  int r = 1;
  for(;n;n>>=1){
    if(n&1)(r = r * x)%=m;
    (x = x * x)%=m;
  }
  return r;
}
bool pal(string s){
  for(int i=0;i<s.size()/2+1;++i)if(s[i]!=s[(int)s.size()-i-1])return false;
  return true;
}
template<class T>
void maxi(T& a, T b){
  a=max(a,b);
}
template<class T>
void mini(T& a, T b){
  a=min(a,b);
}

void done(int tc){
  int n,k; cin >> n >> k;
  while(k--){
    if(n%200==0){
      n/=200;
    }else{
      n *= 1000;
      n += 200;
    }
   // cerr << n << " ";
  }
  cout<<n<<endl;
 // cout <<"Case "<<<<tc<<": "<<((cnt==-1)?"IMPOSSIBLE":cnt)<<endl;
}
  


int32_t main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout<<fixed<<setprecision(10);
 // freopen("input.txt","r",stdin);
  int t; t = 1;
//  cin >> t;
  for(int i=1;i<=t;++i){
    //cout<<"Case #"<<i<<": ";
    //cout<<"Case "<<i<<": ";
    done(i);
  }
}


#include <bits/stdc++.h>

#define FOR(i,x,n) 	for(int i=x; i<n; i++)
#define F0R(i,n) 	FOR(i,0,n)
#define ROF(i,x,n) 	for(int i=n-1; i>=x; i--)
#define R0F(i,n) 	ROF(i,0,n)

#define WTF 		cerr << "WTF" << endl
 
#define IOS 		ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define F 			first
#define S	 		second
#define pb 			push_back
#define mp 			make_pair

#define ALL(x) 		x.begin(), x.end()
#define RALL(x) 	x.rbegin(), x.rend()
#define FILL(a, b) 	memset(a, b, sizeof(a));

#define TOGGLE(x) (x) = 1 - (x)

using namespace std;
typedef double 			db;
typedef long long 		LL;
typedef string 			str;

typedef pair<int, int> 	PII;
typedef pair<LL, LL> 	PLL;

typedef vector<int> 	VI;
typedef vector<LL> 		VLL;
typedef vector<bool> 	VB;
typedef vector<char> 	VC;
typedef vector<PII> 	VPII;
typedef vector<PLL> 	VPLL;
typedef vector<string> 	VSTR;

typedef set<int> 		SI;
typedef set<PII> 		SPII;
typedef set<PLL> 		SPLL;

typedef priority_queue<PII> DIPQ;

const int MAXN = 2e5 + 7;
const int MAXA = 1e7 + 7;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int LOG = 20;
const LL LONG_INF = 1e18;

int n;
str inp;

void Solve () {
	cin >> n >> inp;
	if (inp[0] != inp[n - 1]) {
		cout << 1 << endl;
		return;
	}
	
	else {
		FOR (i, 1, n - 2) {
			if (inp[i] != inp[0] && inp[i + 1] != inp[0]) {
				cout << 2 << endl;
				return;
			}
		}
	}
	
	cout << -1 << endl;
}


int main() {
	IOS;
	Solve ();
}