#include <functional>
#include<algorithm>
#include <utility>
#include <numeric>
#include<iostream>
#include<valarray>
#include<stdio.h>
#include<iomanip>
#include<complex>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<math.h>
#include<list>
#include<set>
#include<map>

#define TRvi(c, it)  for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsf(c, it) for (msf::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmii(c, it) for (mii::iterator it = (c).begin(); it != (c).end(); it++)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(V) (V).begin(), (V).end()
#define msf map<string, float>
#define mii map<int,int>
#define mci map<char,int>
#define vstr vector<string>
#define ii pair<int,int>
#define ci pair<char,int>
#define sf pair<string,float>
#define qi priority_queue<ii >
#define sstr set<string>
#define vii vector<ii>
#define vci vector<ci>
#define vsf vector<sf>
#define vi vector<int>
#define vvi vector<vi>
#define vvc vector<vc>
#define vll vector<lli>
#define vc vector<char>
#define vb vector<bool>
#define sc set<char>
#define si set<int>
#define ln cout<<"\n"
#define re(V) reverse(all(V))
#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL);

typedef long long int lli;
using namespace std;
void pause(){
	#if _DEBUG
	system("pause");
	#endif
}
int main()
{
    fast;

 lli x,y=0,z;
 cin>>z;
while(z>0){
cin>>x>>y;

if(x<=1)
cout<<0<<endl;
else if(x==2)
cout<<y<<endl;
else cout<<2*y<<endl;

z--;
}
}


#include <iostream>

using namespace std;

int main ()
{
    int query;
    cin>>query;

    for(int q=0;q<query;q++)
	{
		int n,m;
		cin>>n>>m;

		if(n==1){
			cout<<'0'<<endl;
			continue;
		}
		else  if(n==2){
			cout<<m<<endl;
			continue;
		}
		else{
			cout<<2*m<<endl;
			continue;
		}

	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long t,n,m;
long long f(long long n,long long m){
	if (n==1) return 0;
	if (n == 2) return m;
	return 2*m;
}
int main()
{
	cin>>t;
	while(t--){
		cin>>n>>m;
		cout<<f(n,m)<<endl;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
long long t,n,m;
long long f(long long n,long long m){
	if (n==1) return 0;
	if (n == 2) return m;
	return 2*m;
}
int main()
{
	cin>>t;
	while(t--){
		cin>>n>>m;
		cout<<f(n,m)<<endl;
	}
	return 0;
}


for i in range(int(input())):
     a, b = map(int,input().split())
     print(min((b*2),((a-1)*b)))


import math
t=int(input())
for _ in range(t):
    n,m=map(int,input().split())
    if(n==1):
        print(0)
    elif(n<=3):
        print(m)
    elif(n>4 and m%2==0):
        print((m//2)*4)
    elif(n>4 and m%2==1):
        print((m//2)*4+2)
    else:
        if(m%2==0):
            print((m//2)*3)
        else:
            print((m//2)*3+2)


for i in range(int(input())):
     a, b = map(int,input().split())
     print(min((b*2),((a-1)*b)))for i in range(int(input())):
     a, b = map(int,input().split())
     print(min((b*2),((a-1)*b)))


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>4):
		print(2*k)
	elif(n==1):
		print(0)
	elif(n==4):
		if(k%2==0):
			print((3*k)//2)
		else:
			print(k+(k//2)+1)
	else:
		print(k)


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>4):
		print(2*k)
	elif(n==1):
		print(0)
	elif(n==4):
		if(n%2==0):
			print((3*n)//2)
		else:
			print(n+n//2+1)
	else:
		print(k)


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>3):
		print(2*k)
	elif(n==1):
		print(0)
	else:
		print(k)


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>3):
		print(2*k)
	else:
		print(k)


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>4):
		print(2*k)
	elif(n==1):
		print(0)
	elif(n==4):
		if(n%2==0):
			print((3*k)//2)
		else:
			print(k+k//2+1)
	else:
		print(k)


t=int(input())
for _ in range(t):
	n,k=map(int,input().split())
	if(n>2):
		print(2*k)
	elif(n==1):
		print(0)
	else:
		print(k)


for i in range(int(input())):
                           n,m=map(int,input().split())

                           if n==1:print("0")

                           elif n==2:print(m)

                           else:
                                print(2*m)


for i in range(int(input())):
                           n,m=map(int,input().split())

                           if n==1:print("0")

                           elif n==2:print(m)

                           else:
                                if m==1:
                                        print("1")
                                else:
                                        print(2*m)


for i in range(int(input())):
                           n,m=map(int,input().split())

                           if n==1:print("0")

                           elif n==3 or n==2:

                                               print(m)

                           elif n==4:
                                      if m==1:print("1")
                                      else:
                                        k=m//2
                                        k=2*m-k
                                        print(k)
                           else:
                                     if m==1:print("1")

                                     else:
                                        print(2*m)


for i in range(int(input())):
                           n,m=map(int,input().split())

                           if n==1:print("0")

                           elif n==3 or n==2:print(m)

                           elif n==4:
                                     if m==1:print("1")
                                     else:
                                        k=m//2
                                        k=2*m-k
                                        print(k)
                           else:
                                     if m==1:print("1")
                                     else: print(2*m)


for i in range(int(input())):
                           n,m=map(int,input().split())

                           if n==1:print("0")

                           elif n==3 or n==2:print(m)

                           elif n==4:
                                      k=m//2
                                      k=2*m-k
                                      print(k)
                           else:
                                     print(2*m)


for k in range(int(input())):
    n, m = list(map(int, input().split()))
    if n == 1:
        print('0')
    elif m > n:
        print(m)
    elif n < m:
        print(n)
    elif n == 2 and m == 2:
        print(n)
    elif n == m:
        print(n*2)
    else:
        print('0')


for k in range(int(input())):
    n, m = list(map(int, input().split()))
    if n == 1:
        print('0')
    elif m > n:
        print(m)
    elif n == 2 and m == 2:
        print(n)
    elif n == m:
        print(n*2)
    else:
        print('0')


def bhaiyya(p):
    if 2 < p:
        return 2
    return p

for k in range(int(input())):
    n, m = list(map(int, input().split()))
    if n == 1:
        print('0')
    else:
        print(bhaiyya(n-1)*m)


# cook your dish here
from math import *
t=int(input())
for _ in range(t):
    n,m=map(int,input().split())
    if n<=2:
        if n==1:
            print('0')
        else:
            print(m)
    else:
        print(2*m)


#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define ll long long int
#define int ll
#define ft    front()
#define pp    pop()
#define ps(a) push(a)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pll pair<int, int>
#define mll map<int, int>
#define un_mll unordered_map<int, int>
#define sll set<int>
#define vll vector<int>
#define qll queue<int>
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define bg begin()
#define ed end()
#define sz size()
#define len length()
#define clc clear()
#define ins(a) insert(a)
#define tp top()
#define itor iterator
#define  rep(x, start, end, step) for(int x = start; x < end; x += step)
#define rrep(x, start, end, step) for(int x = start; x > end; x -= step)
#define inf_1 0x7FFFFFFF
#define inf_2 0x7FFFFFFFFFFFFFFFL
const int zero = 0L;
int prime_table[] = {1009L, 10007L, 100003L, 1000003L, 10000019L, 100000007L, 1000000007L};
#define c_endl {cout << endl;}
#define out(a) (cout << a << endl)
#define hello(a) (cout << "hello" << a << endl)
#define out_v(v) {for(int ___i = 0; ___i < v.size(); ++___i) cout << v[___i] << " "; c_endl;}
#define out_a(a, start, end) {for(int ____j = start; ____j < end; ++____j) cout<< a[____j] << " "; c_endl}
#define fastio {ios::sync_with_stdio(0); cin.tie(0);}
#define mm(a) memset(a, 0, sizeof(a));

const int maxn_1 = 3.1e1;
const int maxn_2 = 3.1e2;
const int maxn_3 = 3.1e3;
const int maxn_4 = 3.1e4;
const int maxn_5 = 3.1e5;
const int maxn_6 = 3.1e6;

bool judge(const string &s){
    int n = s.len;
    bool ok_flag = true;
    rep(i, 0, n / 2, 1){
        if(s[i] != s[n - i - 1]){
            ok_flag = false;
            break;
        }
    }
    return ok_flag;
}
signed main(){
    fastio;
    string s;
    cin >> s;
    int n = s.len;
    int ans;
    bool ok_flag_2 = false;
    rep(i, 1, n / 2, 1){
        if(s[i] != s[0]){
            ok_flag_2 = true;
            break;
        }
    }
    if(ok_flag_2 == false){
        out("Impossible");
    }
    else{
        ans = 2;
        rep(i, 1, n, 1){
            string a, b;
            a = b = "";
            rep(j, 0, n, 1){
                if(j < i){
                    a += s[j];
                }
                else{
                    b += s[j];
                }
            }
            string new_s = b + a;
            if(new_s != s && judge(new_s)){
                ans = 1;
            }
        }
        out(ans);
    }
    return 0;
}


#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define ll long long int
#define int ll
#define ft    front()
#define pp    pop()
#define ps(a) push(a)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pll pair<int, int>
#define mll map<int, int>
#define un_mll unordered_map<int, int>
#define sll set<int>
#define vll vector<int>
#define qll queue<int>
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define bg begin()
#define ed end()
#define sz size()
#define len length()
#define clc clear()
#define ins insert()
#define tp top()
#define itor iterator
#define  rep(x, start, end, step) for(int x = start; x < end; x += step)
#define rrep(x, start, end, step) for(int x = start; x > end; x -= step)
#define inf_1 0x7FFFFFFF
#define inf_2 0x7FFFFFFFFFFFFFFFL
const int zero = 0L;
int prime_table[] = {1009L, 10007L, 100003L, 1000003L, 10000019L, 100000007L, 1000000007L};
#define c_endl {cout << endl;}
#define out(a) (cout << a << endl)
#define hello(a) (cout << "hello" << a << endl)
#define out_v(v) {for(int ___i = 0; ___i < v.size(); ++___i) cout << v[___i] << " "; c_endl;}
#define out_a(a, start, end) {for(int ____j = start; ____j < end; ++____j) cout<< a[____j] << " "; c_endl}
#define fastio {ios::sync_with_stdio(0); cin.tie(0);}
#define mm(a) memset(a, 0, sizeof(a));

const int maxn_1 = 3.1e1;
const int maxn_2 = 3.1e2;
const int maxn_3 = 3.1e3;
const int maxn_4 = 3.1e4;
const int maxn_5 = 3.1e5;
const int maxn_6 = 3.1e6;

bool judge(const string &s, int start, int end){
    bool ok_flag = true;
    int n = end - start + 1;
    rep(i, 0, n / 2, 1){
        if(s[start + i] != s[end - i]){
            ok_flag = false;
            break;
        }
    }
    return ok_flag;
}
signed main(){
    fastio;
    string s;
    cin >> s;
    int n = s.len;
    set<char> _s;
    rep(i, 0, n, 1){
        _s.insert(s[i]);
    }
    int ans = 0;
    int start, end;
    start = 0, end = n - 1;
    bool odd_flag = false;
    bool ok_flag = false;
    while(1){
        int cur_length = end - start + 1;
        if(cur_length == 1){
            break;
        }
        int mid = (start + end) / 2;
        if(cur_length % 2 == 1){
            odd_flag = true;
            start = mid + 1;
        }
        else{
            start = mid + 1;
        }
        // cout << "start = " << start << " end = " << end << endl;
        if(!judge(s, start, end)){
            // out((end - start + 1));
            // if((end - start + 1) % 2 == 1){
            //     odd_flag = true;
            // }
            ok_flag = true;
            break;
        }
    }
    if(ok_flag){
        if(odd_flag){
            out("2");
        }
        else{
            out("1");
        }
    }
    else{
        if(_s.size() > 2){
            out("2");
        }
        else{
            out("Impossible");
        }
    }
    return 0;
}


#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
using namespace std;
#define ll long long int
#define int ll
#define ft    front()
#define pp    pop()
#define ps(a) push(a)
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define pll pair<int, int>
#define mll map<int, int>
#define un_mll unordered_map<int, int>
#define sll set<int>
#define vll vector<int>
#define qll queue<int>
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define bg begin()
#define ed end()
#define sz size()
#define len length()
#define clc clear()
#define ins insert()
#define tp top()
#define itor iterator
#define  rep(x, start, end, step) for(int x = start; x < end; x += step)
#define rrep(x, start, end, step) for(int x = start; x > end; x -= step)
#define inf_1 0x7FFFFFFF
#define inf_2 0x7FFFFFFFFFFFFFFFL
const int zero = 0L;
int prime_table[] = {1009L, 10007L, 100003L, 1000003L, 10000019L, 100000007L, 1000000007L};
#define c_endl {cout << endl;}
#define out(a) (cout << a << endl)
#define hello(a) (cout << "hello" << a << endl)
#define out_v(v) {for(int ___i = 0; ___i < v.size(); ++___i) cout << v[___i] << " "; c_endl;}
#define out_a(a, start, end) {for(int ____j = start; ____j < end; ++____j) cout<< a[____j] << " "; c_endl}
#define fastio {ios::sync_with_stdio(0); cin.tie(0);}
#define mm(a) memset(a, 0, sizeof(a));

const int maxn_1 = 3.1e1;
const int maxn_2 = 3.1e2;
const int maxn_3 = 3.1e3;
const int maxn_4 = 3.1e4;
const int maxn_5 = 3.1e5;
const int maxn_6 = 3.1e6;

bool judge(const string &s, int start, int end){
    bool ok_flag = true;
    int n = end - start + 1;
    rep(i, 0, n / 2, 1){
        if(s[start + i] != s[end - i]){
            ok_flag = false;
            break;
        }
    }
    return ok_flag;
}
signed main(){
    fastio;
    string s;
    cin >> s;
    int n = s.len;
    int ans = 0;
    int start, end;
    start = 0, end = n - 1;
    bool odd_flag = false;
    bool ok_flag = false;
    while(1){
        int cur_length = end - start + 1;
        if(cur_length == 1){
            break;
        }
        int mid = (start + end) / 2;
        if(cur_length % 2 == 1){
            odd_flag = true;
            start = mid + 1;
        }
        else{
            start = mid;
        }
        if(!judge(s, start, end)){
            if((end - start + 1) % 2 == 1){
                odd_flag = true;
            }
            ok_flag = true;
            break;
        }
    }
    if(ok_flag){
        if(odd_flag){
            out("2");
        }
        else{
            out("1");
        }
    }
    else{
        out("Impossible");
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool same(string s, int l, int r){
	for(register int i = 0, j = l; i < n; ++ i, ++ j)
		if(s[j] != a[i]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	//cout << s << endl;
	return is_palindrome(s, pos + 1, n + pos) && (!same(s, pos + 1, n + pos));
}
inline bool False(void){
	if((n % 2) == 1 && is_palindrome(a, 0, n / 2 - 1) == true) return true;
	bool flag = 1;
	for(register int i = 0; i < n; ++ i)
		if(a[0] != a[i]) flag = 0;
	if(flag == 1) return true;
	return false;
}
inline void work(void){
	if(False()){
		 printf("Impossible"); return;
	}
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	//cout << s << endl;
	return is_palindrome(s, pos + 1, n + pos);
}
inline bool False(void){
	for(register int i = 0; i < n; ++ i)
		if(a[0] != a[i]) return false;
	return true;
}
inline void work(void){
	if(False()){
	     printf("Impossible"); return;
	}
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool same(string s, int l, int r){
	for(register int i = 0, j = l; i < n; ++ i, ++ j)
		if(s[j] != a[i]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	return is_palindrome(s, pos + 1, n + pos) && (!same(s, pos + 1, n + pos));
}
bool always(int l, int r){
	for(register int i = l; i <= r; ++ i) if(a[l] != a[i]) return false;
	return true;
}
inline bool False(void){
	if((n % 2) == 1 && always(0, n / 2 - 1)) return true;
	//if((n % 2) == 1 && is_palindrome(a, 0, n / 2 - 1) == true) return true;
	if(always(0, n - 1)) return true;
	return false;
}
inline void work(void){
	if(False()){
		 printf("Impossible"); return;
	}
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool same(string s, int l, int r){
	for(register int i = 0, j = l; i < n; ++ i, ++ j)
		if(s[j] != a[i]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	//cout << s << endl;
	return is_palindrome(s, pos + 1, n + pos) && (!same(s, pos + 1, n + pos));
}
inline bool False(void){
	//if((n % 2) == 1 && is_palindrome(a, 0, n / 2 - 1) == true) return true;
	bool flag = 1;
	for(register int i = 0; i < n; ++ i)
		if(a[0] != a[i]) flag = 0;
	if(flag == 1) return true;
	return false;
}
inline void work(void){
	if(False()){
		 printf("Impossible"); return;
	}
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	//cout << s << endl;
	return is_palindrome(s, pos + 1, n + pos);
}
inline bool False(void){
	for(register int i = 0; i < n; ++ i)
		if(a[0] != a[i]) return false;
	return true;
}
inline void work(void){
	if(False()) printf("Impossible");
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
const int MAXN = 5000 + 10;
string a;
int n;
inline void init(void){
	cin >> a; n = a.size();
}
bool is_palindrome(string s, int l, int r){
	for(; l <= r; ++l, -- r)
		if(s[l] != s[r]) return false;
	return true;
}
bool same(string s, int l, int r){
	for(register int i = 0, j = l; i < n; ++ i, ++ j)
		if(s[j] != a[i]) return false;
	return true;
}
bool check(int pos, string s){
	for(register int i = 0; i <= pos; ++ i)
		s.push_back(s[i]);
	//cout << s << endl;
	return is_palindrome(s, pos + 1, n + pos) && (!same(s, pos + 1, n + pos));
}
inline bool False(void){
	for(register int i = 0; i < n; ++ i)
		if(a[0] != a[i]) return false;
	if((n % 2) == 1 && is_palindrome(a, 0, n / 2 - 1) == true) return false;
	return true;
}
inline void work(void){
	if(False()){
		 printf("Impossible"); return;
	}
	for(register int i = 0; i < n - 1; ++ i){
		if(check(i, a)) {
			printf("1"); return;
		}
	}
	printf("2");
}

int main(){
	init();
	work();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=300000;
char s[N];
int t;
inline int cmp(char *s,int l)
{
    if(l%2==1)
    {
        int mid=l/2;
        bool f=1;
        for(int i=1,j=mid;i<=mid;i++)
        {
            if(s[i]!=s[1])
            {
                f=0;
                break;
            }
        }
        if(f) return 0;
        return 2;
    }
    bool f=1;
    int mid=l/2;
    for(int i=1,j=mid;i<=mid;i++,j--)
    {
        if(s[i]!=s[1])
        {
            f=0;
            break;
        }
    }
    if(f==1) return 0;
    f=1;
    for(int i=1,j=mid;i<=mid;i++,j--)
    {
        if(s[i]!=s[j])
        {
            f=0;
            break;
        }
    }
    if(f==1) return 2;//return cmp(s,mid);
    return 1;
}
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",s+1);
        int n=strlen(s+1);
        int k=cmp(s,n);
        if(k==0) puts("Impossible");
        else cout<<k<<endl;
    }
 //system("pause");
}


#include<bits/stdc++.h>
using namespace std;
const int N=300000;
char s[N];
int t;
inline int cmp(char *s,int l)
{
    if(l%2==1)
    {
        int mid=l/2;
        bool f=1;
        for(int i=1,j=mid;i<=mid;i++,j--)
        {
            if(s[i]!=s[j])
            {
                f=0;
                break;
            }
        }
        if(f) return 2;
        return 1;
    }
    bool f=1;
    int mid=l/2;
    for(int i=1,j=mid;i<=mid;i++,j--)
    {
        if(s[i]!=s[j])
        {
            f=0;
            break;
        }
    }
    if(f==1) return cmp(s,mid);
    return 1;
}
int main()
{
    ///scanf("%d",&t);
    t=1;
    while(t--)
    {
        scanf("%s",s+1);
        int n=strlen(s+1);
        int l=n;
        if(l%2==1)
        {
            int mid=l/2;
            bool f=1;
            for(int i=1,j=mid;i<=mid;i++)
            {
                if(s[i]!=s[1])
                {
                    f=0;
                    break;
                }
            }
            if(f) puts("Impossible");
            else puts("2");
            continue;
        }
        bool f=1;
        int mid=l/2;
        for(int i=1,j=mid;i<=mid;i++,j--)
        {
            if(s[i]!=s[1])
            {
                f=0;
                break;
            }
        }
        if(f==1) {puts("Impossible");continue;}
        int k=cmp(s,n);
        if(k==0) puts("Impossible");
        else cout<<k<<endl;
    }
// system("pause");
}


#include<bits/stdc++.h>
using namespace std;
const int N=300000;
char s[N];
int t;
inline int cmp(char *s,int l)
{
    bool f=1;
    int mid=l/2;
    for(int i=1,j=mid;i<=mid;i++,j--)
    {
        if(s[i]!=s[j])
        {
            f=0;
            break;
        }
    }
    if(f==1&&l%2==1) return 2;
    if(f==1) return  cmp(s,mid);
    if(!f&&(l%2==1))
        return 2;
    return 1;
}
int main()
{
    ///scanf("%d",&t);
    t=1;
    while(t--)
    {
        scanf("%s",s+1);
        int n=strlen(s+1);
        int l=n;
        if(l%2==1)
        {
            int mid=l/2;
            bool f=1;
            for(int i=1,j=mid;i<=mid;i++)
            {
                if(s[i]!=s[1])
                {
                    f=0;
                    break;
                }
            }
            if(f) puts("Impossible");
            else puts("2");
            continue;
        }
        bool f=1;
        int mid=l/2;
        for(int i=1,j=mid;i<=mid;i++,j--)
        {
            if(s[i]!=s[1])
            {
                f=0;
                break;
            }
        }
        if(f==1) {puts("Impossible");continue;}
        int k=cmp(s,n);
        if(k==0) puts("Impossible");
        else cout<<k<<endl;
    }
 //system("pause");
}
/*
mooboooombomboomobmmmboombmooboooombomboomobmmmboommooboooombomboomobmmmboombmooboooombomboomobmmmboom
*/


#include<bits/stdc++.h>
using namespace std;
const int N=300000;
char s[N];
int t;
inline int cmp(char *s,int l)
{
    if(l%2==1)
    {
        int mid=l/2;
        bool f=1;
        for(int i=1,j=mid;i<=mid;i++,j--)
        {
            if(s[i]!=s[j])
            {
                f=0;
                break;
            }
        }
        if(f) return 2;
        return 1;
    }
    bool f=1;
    int mid=l/2;
    for(int i=1,j=mid;i<=mid;i++,j--)
    {
        if(s[i]!=s[j])
        {
            f=0;
            break;
        }
    }
    if(f==1) return cmp(s,mid);
    return 1;
}
int main()
{
    ///scanf("%d",&t);
    t--;
    while(t--)
    {
        scanf("%s",s+1);
        int n=strlen(s+1);
        int l=n;
        if(l%2==1)
        {
            int mid=l/2;
            bool f=1;
            for(int i=1,j=mid;i<=mid;i++)
            {
                if(s[i]!=s[1])
                {
                    f=0;
                    break;
                }
            }
            if(f) puts("Impossible");
            else puts("2");
            continue;
        }
        bool f=1;
        int mid=l/2;
        for(int i=1,j=mid;i<=mid;i++,j--)
        {
            if(s[i]!=s[1])
            {
                f=0;
                break;
            }
        }
        if(f==1) {puts("Impossible");continue;}
        int k=cmp(s,n);
        if(k==0) puts("Impossible");
        else cout<<k<<endl;
    }
 //system("pause");
}


#include<bits/stdc++.h>
using namespace std;
string s,st;
int len,re;
bool hw(string st){
	for(int i=0;i<st.length()/2;++i){
		int j=st.length()-i-1;
		if(st[i]!=st[j]){
			return 0;
		}
	}
	return 1;
}
bool check(string st){
	if(st.length()&1)return hw(st);
	if(!hw(st))return 0;
	else return check(st.substr(0,st.length()/2));
}
template<typename TP>
void write(TP x){
	if(x>=10)write(x/10);
	putchar('0'+x%10);
}
int main()
{
	cin>>s;
	len=s.length();
	bool flag=0;
	for(int i=1;i<len/2;++i){
		if(s[i]!=s[i-1]){
			flag=1;
			break;
		}
	}
	if(!flag){
		puts("Impossible");
		return 0;
	}
	if(len&1)re=2;
	else{
		st=s;
		if(check(s))re=2;
		else re=1;
	}
	write(re);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template<typename TP>
inline void read(TP &number){
	number=0;int w7=1;
	char ch7=getchar();
	while(ch7<'0'||ch7>'9'){if(ch7=='-')w7=-1;ch7=getchar();}
	while(ch7>='0'&&ch7<='9'){number=(number<<3)+(number<<1)+ch7-'0';ch7=getchar();}
	number*=w7;
}
char s[500005];
int slen;
bool check(int l,int r){
	int i,j;
	for(i=l;;i++){
		j=r-(i-l);
		if(s[i]!=s[j])return 0;
		if(i>j)return 1;
	}
}
int main(){
	scanf("%s",s+1);
	slen=strlen(s+1);
	int i,j,mid;
	if(slen&1){
		mid=(1+slen)>>1;
		if(check(1,mid-1)){
			printf("Impossible");
			return 0;
		}
		else printf("2");
		return 0;
	}
	mid=(1+slen)>>1;
	if(!check(1,mid)){
		printf("1");return 0;
	}
	if(mid%2==0){
		if(s[1]==s[mid/2]){
			printf("Impossible");return 0;
		}
		printf("1");
		return 0;
	}
	else printf("Impossible");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
template<typename TP>
inline void read(TP &number){
	number=0;int w7=1;
	char ch7=getchar();
	while(ch7<'0'||ch7>'9'){if(ch7=='-')w7=-1;ch7=getchar();}
	while(ch7>='0'&&ch7<='9'){number=(number<<3)+(number<<1)+ch7-'0';ch7=getchar();}
	number*=w7;
}
char s[500005];
int slen;
bool check(int l,int r){
	int i,j;
	for(i=l;;i++){
		j=r-(i-l);
		if(i>=j)return 1;
		if(s[i]!=s[j])return 0;
	}
}
int main(){
	scanf("%s",s+1);
	slen=strlen(s+1);
	int i,j,mid;
	if(slen&1){
		mid=(1+slen)>>1;
		if(check(1,mid-1)){
			printf("Impossible");
			return 0;
		}
		else printf("2");
		return 0;
	}
	mid=slen>>1;
	if(!check(1,mid)){
		printf("1");return 0;
	}
	if(mid%2==0){
		if(s[1]==s[mid/2]){
			printf("Impossible");
			return 0;
		}
		printf("1");
		return 0;
	}
	else printf("Impossible");
	return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 5005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
        return 0;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            x = is_p(s1);
            if(x)continue;
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag)
            {
                cout << "1" << endl;
                return 0;
            }
        }
    }
    if(n % 2)
    {
        int a = 0;
        int k = n / 2;
        for(int i = k - 1;k >= 1;k --)
        {
            if(s[i] != s[0]) a = 1;
        }
        if(a == 0) cout << "Impossible" << endl;
        else cout << "2" << endl;
    }
    else cout << "2" << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 5005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            x = is_p(s1);
            if(x)continue;
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag)
            {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;k >= 1;k --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 100005;
char s[maxn];

int main()
{
    cin >> s;
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag == 0)continue;
            int l = 0,r = n - 1;
            while(l <= r)
            {
                if(s1[l] != s1[r])
                {
                    x = 1;
                }
                l ++;
                r --;
            }
            if(x == 0) {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;i >= 1;i --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 50005;
char s[maxn];

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag == 0)continue;
            int l = 0,r = n - 1;
            while(l <= r)
            {
                if(s1[l] != s1[r])
                {
                    x = 1;
                }
                l ++;
                r --;
            }
            if(x == 0) {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;k >= 1;k --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 50005;
char s[maxn];

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag == 0)continue;
            int l = 0,r = n - 1;
            while(l <= r)
            {
                if(s1[l] != s1[r])
                {
                    x = 1;
                    break;
                }
                l ++;
                r --;
            }
            if(x == 0) {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;k >= 1;k --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 5005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag == 0)continue;
            x = is_p(s1);
            if(x == 0) {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;k >= 1;k --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 5005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0) {
            cout << "Impossible" << endl;
            return 0;
    }
    else
    {
        int x = 0,flag = 0;
    for(int p = 0;p < n;p ++)
    {
        int t = 0;
        for(int k = p;k < n;k ++)
        {
            s1[t ++] = s[k];
        }
        for(int k = 0;k < p;k ++)
        {
            s1[t ++] = s[k];
        }
        x = is_p(s1);
        if(x)continue;
        else
        {
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                    {
                        flag = 0;
                        cout << "1" << endl;
                        return 0;
                    }
                else {
                    flag = 1;
                }
            }
        }
        if(flag) continue;
    }
    }
    if(n % 2)
    {
        int a = 0;
        int k = n / 2;
        for(int i = k - 1;k >= 1;k --)
        {
            if(s[i] != s[0]) a = 1;
        }
        if(a == 0) cout << "Impossible" << endl;
        else cout << "2" << endl;
    }
    else cout << "2" << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 5005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 1;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i <= n / 2;i ++)
    {
        if(s[i] == s[0]) cnt ++;
        if(cnt == n / 2)
            {
                printf("Impossible\n");
                return 0;
            }
    }
    int x = 0,flag = 0;
    for(int p = 0;p < n;p ++)
    {
        int t = 0;
        for(int k = p;k < n;k ++)
        {
            s1[t ++] = s[k];
        }
        for(int k = 0;k < p;k ++)
        {
            s1[t ++] = s[k];
        }
        x = is_p(s1);
        if(x)continue;
        else
        {
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                    {
                        flag = 0;
                        cout << "1" << endl;
                        return 0;
                    }
                else {
                    flag = 1;
                }
            }
        }
        if(flag) continue;
    }
    cout << "2" << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>

using namespace std;

const int maxn = 50005;
char s[maxn];

int is_p(char s1[])
{
    int x = 0;
    int l = 0,r = strlen(s1) - 1;
    while(l <= r)
    {
        if(s1[l] != s1[r])
        {
            x = 1;
            break;
        }
        l ++;
        r --;
    }
    return x;
}

int main()
{
    gets(s);
    int cnt = 0;
    char s1[maxn];
    int n = strlen(s);
    for(int i = 1;i < n;i ++)
    {
        if(s[i] != s[0]) cnt = 1;
    }
    if(cnt == 0)
    {
        cout << "Impossible" << endl;
    }
    else
    {
        for(int p = 1;p < n;p ++)
        {
            int t = 0;
            int x = 0,flag = 0;
            for(int k = p;k < n;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int k = 0;k < p;k ++)
            {
                s1[t ++] = s[k];
            }
            for(int i = 0;i < n;i ++)
            {
                if(s1[i] != s[i])
                {
                    flag = 1;
                }
            }
            if(flag == 0)continue;
            x = is_p(s1);
            if(x == 0) {
                cout << "1" << endl;
                return 0;
            }
        }
        if(n % 2)
        {
            int a = 0;
            int k = n / 2;
            for(int i = k - 1;k >= 1;k --)
            {
                if(s[i] != s[0]) a = 1;
            }
            if(a == 0) cout << "Impossible" << endl;
            else cout << "2" << endl;
        }
        else cout << "2" << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, R> a) {cerr << "(" << a.ST << ", " << a.ND << ")";}
template<class T> void db(V<T> v)
{ cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

int main()
{
	ios_base::sync_with_stdio(0);
 	cin.tie(0);

	string str;
	cin >> str;

	int n = S(str);
	if(n % 2 == 1)
	{
		bool only_one = true;
		REP(i, n) if(i != n / 2 && str[i] != str[0]) only_one = false;

		if(only_one)
			cout << "Impossible\n";
		else
			cout << "2\n";
	}
	else
	{
		bool only_one = true;
		REP(i, n) if(str[i] != str[0]) only_one = false;

		bool same = true;
		int half = n / 2;
		REP(i, half) if(str[i] != str[i + half]) same = false;

		if(only_one)
			cout << "Impossible\n";
		else if(!same || n % 4 == 0)
			cout << "1\n";
		else
			cout << "2\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, R> a) {cerr << "(" << a.ST << ", " << a.ND << ")";}
template<class T> void db(V<T> v)
{ cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

int main()
{
	ios_base::sync_with_stdio(0);
 	cin.tie(0);

	string str;
	cin >> str;

	int n = S(str);
	if(n % 2 == 1)
	{
		bool only_one = true;
		REP(i, n) if(i != n / 2 && str[i] != str[0]) only_one = false;

		if(only_one)
			cout << "Impossible\n";
		else
			cout << "2\n";
	}
	else
	{
		bool only_one = true;
		REP(i, n) if(str[i] != str[0]) only_one = false;
		bool same = true;
		int half = n / 2;
		REP(i, half) if(str[i] != str[i + half]) same = false;

		bool is_half_pal = true;
		if(n % 4 != 0) is_half_pal = false;
		else REP(i, half / 2) if(str[i] != str[half - i - 1]) is_half_pal = false;

		if(only_one)
			cout << "Impossible\n";
		else if(!same || is_half_pal)
			cout << "1\n";
		else
			cout << "2\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, R> a) {cerr << "(" << a.ST << ", " << a.ND << ")";}
template<class T> void db(V<T> v)
{ cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a) { cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

int main()
{
	ios_base::sync_with_stdio(0);
 	cin.tie(0);

	string str;
	cin >> str;

	int n = S(str);
	if(n % 2 == 1)
	{
		bool only_one = true;
		REP(i, n) if(i != n / 2 && str[i] != str[0]) only_one = false;

		if(only_one)
			cout << "Impossible\n";
		else
			cout << "2\n";
	}
	else
	{
		FOR(i, 1, n - 1)
		{
			string s = str;
			REP(j, n)
			{
				int pos = (j + i) % n;
				s[pos] = str[j];
			}

			bool is_palindrome = true;
			REP(j, n / 2)
			{
				int pos = n - j - 1;
				if(s[j] != s[pos]) is_palindrome = false;
			}

			if(is_palindrome && s != str)
			{
				cout << 1 << "\n";
				return 0;
			}
		}

		bool only_one = true;
		REP(i, n) if(str[i] != str[0]) only_one = false;

		bool same = true;
		int half = n / 2;
		REP(i, half) if(str[i] != str[i + half]) same = false;

		if(only_one)
			cout << "Impossible\n";
		else if(!same || n % 4 == 0)
			cout << "1\n";
		else
			cout << "2\n";
	}
}


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

#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
#define ST first
#define ND second
#define V vector
#define RS resize
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define S(a) (int)a.size()

template<class T> void db(T a) { cerr << a; }
template<class L, class R> void db(pair<L, R> a) { cerr << "(" << a.ST << ", " << a.ND << ")"; }
template<class T> void db(V<T> v) { cerr << "{"; REP(i, S(v)) cerr << (i != 0 ? ", " : ""), db(v[i]); cerr << "}"; }
template<class T> void dump(const char *s, T a){ cerr << s << ": "; db(a); cerr << "\n"; }
template<class T, class... TS> void dump(const char *s, T a, TS... x)
{ while(*s != ',') cerr<< *s++; cerr << ": "; db(a); dump(s + 1, x...); }

#ifdef DEBUG
#define DB(...) dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define DB(...)
#endif

using LL = long long;
using PII = pair<int, int>;
using VI = V<int>;
using VLL = V<LL>;
using VVI = V<VI>;
using VPII = V<PII>;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

	string str;
	cin >> str;

	int n = S(str);
	bool all_letters_same = true;
	REP(i, n) if(str[i] != str[0] && i * 2 + 1 != n) all_letters_same = false;
	if(all_letters_same)
	{
		cout << "Impossible\n";
		return 0;
	}

	FOR(q, 1, n - 1)
	{
		string s = str;
		REP(i, n)
		{
			int pos = (i + q) % n;
			s[i] = str[pos];
		}

		DB(q, s);

		bool is_palindrome = true;
		REP(i, n)
		{
			int pos = n - 1 - i;
			if(s[i] != s[pos]) is_palindrome = false;
		}

		if(is_palindrome && str != s)
		{
			cout << 1 << "\n";
			return 0;
		}
	}

	cout << 2 << "\n";
}


#include <bits/stdc++.h>

using namespace std;

bool check_pal(string &s){
    for(int i=0;i<s.size();++i){
        if(s[i]!=s[s.size()-i-1]) return 0;
    }
    return 1;
}

int main(){
    string s;cin >> s;
    set<int> S;
    for(int i=0;i<s.size();++i){
        S.insert(s[i]);
    }
    if(S.size()==1){
        cout << "Impossible" << endl;return 0;
    }
    if(s.size()%2){
        int u=s.size()/2;
        S.clear();
        for(int i=0;i<s.size();++i){if(i==u) continue;
        S.insert(s[i]);
    }
        if(S.size()==1){
            cout << "Impossible" << endl;return 0;
        }
    }

        for(int i=1;i<s.size();++i){
            string t="";
            for(int k=i;k<s.size();++k){
                t+=s[k];
            }
            for(int k=0;k<i;++k){
                t+=s[k];
            }
            if(check_pal(t) && t!=s){
                cout << "1" << endl;return 0;
            }
        }
        cout << "2" << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool check_pal(string &s){
    for(int i=0;i<s.size();++i){
        if(s[i]!=s[s.size()-i-1]) return 0;
    }
    return 1;
}

int main(){
    string s;cin >> s;
    set<int> S;
    for(int i=0;i<s.size();++i){
        S.insert(s[i]);
    }
    if(S.size()==1){
        cout << "Impossible" << endl;return 0;
    }
    if(s.size()%2){
        int u=s.size()/2;
        S.erase(s[u]);
        if(S.size()==1){
            cout << "Impossible" << endl;return 0;
        }
    }

        for(int i=1;i<s.size();++i){
            string t="";
            for(int k=i;k<s.size();++k){
                t+=s[k];
            }
            for(int k=0;k<i;++k){
                t+=s[k];
            }
            if(check_pal(t) && t!=s){
                cout << "1" << endl;return 0;
            }
        }
        cout << "2" << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool check_pal(string &s){
    for(int i=0;i<s.size();++i){
        if(s[i]!=s[s.size()-i-1]) return 0;
    }
    return 1;
}

int main(){
    string s;cin >> s;
    set<int> S;
    for(int i=0;i<s.size();++i){
        S.insert(s[i]);
    }
    if(S.size()==1){
        cout << "Impossible" << endl;return 0;
    }

        for(int i=1;i<s.size();++i){
            string t="";
            for(int k=i;k<s.size();++k){
                t+=s[k];
            }
            for(int k=0;k<i;++k){
                t+=s[k];
            }
            if(check_pal(t)){
                cout << "1" << endl;return 0;
            }
        }
        cout << "2" << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool check_pal(string &s){
    for(int i=0;i<s.size();++i){
        if(s[i]!=s[s.size()-i-1]) return 0;
    }
    return 1;
}

int main(){
    string s;cin >> s;
    set<int> S;
    for(int i=0;i<s.size();++i){
        S.insert(s[i]);
    }
    if(S.size()==1){
        cout << "Impossible" << endl;return 0;
    }

        for(int i=1;i<s.size();++i){
            string t="";
            for(int k=i;k<s.size();++k){
                t+=s[k];
            }
            for(int k=0;k<i;++k){
                t+=s[k];
            }
            if(check_pal(t) && t!=s){
                cout << "1" << endl;return 0;
            }
        }
        cout << "2" << endl;

    return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;
	if(!equal(l,r-len+1,len))return ((r-l+1)&1)?k+=2:++k,void();
	solve(l,l+len-1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	bool flag=1;
	fp(i,2,n)if(s[i]!=s[i-1]){flag=0;break;}
	if(flag)return puts("Impossible"),0;
	if(n&1^1)return puts("1"),0;
	puts("2");
	return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;
	if(!equal(l,r-len+1,len))return ((r-l+1)&1)?k=2:k=1,void();
	solve(l,l+len-1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	solve(1,n);
	printf("%d\n",k);
	return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;((r-l+1)&1)?k+=2:++k;
	if(!equal(l,r-len+1,len))return;
	solve(l,l+len-1);
}
inline bool rev(int a,int len){
	fp(i,1,len>>1)if(s[a+i-1]!=s[a+len-i])return false;
	return true;
}
bool calc(){
	fp(i,n+1,n+n)s[i]=s[i-n];
	fp(i,1,n)if(rev(i,n)&&!equal(1,i,n))return true;
	return false;
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	if(calc())return puts("1"),0;
	solve(1,n);
	printf("%d\n",k);
	return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;((r-l+1)&1)?k=2:0;
	if(!equal(l,r-len+1,len))return !k?k=1:0,void();
	if(((r-l+1)&1)&&!equal(l,r-len,len+1))return k=2,void();
	solve(l,l+len-1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	solve(1,n);
	printf("%d\n",k);
	return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;((r-l+1)&1)?k=2:0;
	if(!equal(l,r-len+1,len))return !k?k=1:0,void();
	if(((r-l+1)&1)&&len+1<n-len&&!equal(l,r-len,len+1))return k=2,void();
	solve(l,l+len-1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	solve(1,n);
	printf("%d\n",k);
	return 0;
}


//minamoto
#include<bits/stdc++.h>
#define R register
#define inf 0x3f3f3f3f
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(char *s){
	R int len=0;R char ch;while(((ch=getc())>'z'||ch<'a'));
	for(s[++len]=ch;(ch=getc())>='a'&&ch<='z';s[++len]=ch);
	return s[len+1]='\0',len;
}
const int N=10005;
char s[N];int n,k,g;
inline bool equal(int a,int b,int len){
	fp(i,1,len)if(s[a+i-1]!=s[b+i-1])return false;
	return true;
}
void solve(int l,int r){
	if(l==r){puts("Impossible");exit(0);};
	int len=(r-l+1)>>1;((r-l+1)&1)?k=2:0;
	if(!equal(l,r-len+1,len))return !k?k=1:0,void();
	solve(l,l+len-1);
}
int main(){
//	freopen("testdata.in","r",stdin);
	n=read(s);
	solve(1,n);
	printf("%d\n",k);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,cnt,i,j,flag,m;
char s[101010],a[101010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=2;i<=n;i++)if(s[i]!=s[i-1]){
		flag=1;break;
	}
	if(!flag)return puts("Impossible"),0;
	for(i=1;i<n;i++){
		cnt=0;
		for(j=i+1;j<=n;j++)a[++cnt]=s[j];
		for(j=1;j<=i;j++)a[++cnt]=s[j];
		flag=0;
		for(j=1;j<=n;j++)if(s[j]!=a[j]){
			flag=1;break;
		}
		if(flag)continue;
		for(j=1;j<n/2;j++)if(a[j]!=a[n-j+1]){
			flag=1;break;
		}
		if(flag)continue;
		puts("1");
		return 0;
	}
	puts("2");
	/*if(n%2==1)printf("2");
	 else{
	 	m=n/2;
	 	flag=0;
	 	for(i=1;i<=m/2;i++)if(s[i]!=s[m-i+1]){
	 		flag=1;break;
		 }
		if(flag)puts("1");
		 else puts("2");
	 }*/
}


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

string s;

bool check(string s){
    for (int i = 1;i < (int)s.size()/2;i++){
        if (s[i]!=s[0]) return true;
    }
    return false;
}

bool ispar(string s){
    for (int i = 0;i < (int)s.size()/2;i++){
        if (s[i]!=s[(int)s.size()-i-1]){
            return false;
        }
    }
    return true;
}

bool ok(string s){
    string t = s;
    for (int i = 0;i < (int)s.size();i++){
        t = t.substr(1) + t[0];
        if (t!=s && ispar(t)) return true;
    }
    return false;
}

int main(){
    cin >> s;
    if (!check(s)){
        cout<<"Impossible"<<endl;
    }else if (ok(s)){
        cout<<1<<endl;
    }else{
        cout<<2<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,cnt,i,j,flag,m;
char s[101010],a[101010];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=2;i<=n;i++)if(s[i]!=s[i-1]){
		flag=1;break;
	}
	if(!flag)return puts("Impossible"),0;
	for(i=1;i<n;i++){
		cnt=0;
		for(j=i+1;j<=n;j++)a[++cnt]=s[j];
		for(j=1;j<=i;j++)a[++cnt]=s[j];
		flag=0;
		for(j=1;j<=n;j++)if(s[j]!=a[j]){
			flag=1;break;
		}
		if(!flag)continue;
		flag=0;
		for(j=1;j<n/2;j++)if(a[j]!=a[n-j+1]){
			flag=1;break;
		}
		if(flag)continue;
		puts("1");
		return 0;
	}
	puts("2");
	/*if(n%2==1)printf("2");
	 else{
	 	m=n/2;
	 	flag=0;
	 	for(i=1;i<=m/2;i++)if(s[i]!=s[m-i+1]){
	 		flag=1;break;
		 }
		if(flag)puts("1");
		 else puts("2");
	 }*/
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int f=1,a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-f;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a*f;
}

bool hw(string st)
{
	for(int i=0;i<st.length()/2;++i){
		int j=st.length()-i-1;
		if(st[i]!=st[j]){
			return 0;
		}
	}
	return 1;
}

bool check(string st)
{
	if(st.length()==1){
		return 0;
	}
	if(!hw(st)){
		return 1;
	}else{
		return check(st.substr(0,st.length()/2));
	}
}

string s;
int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>s;
	if(check(s)){
		if(s.length()&1){
			cout<<2<<endl;
		}else{
			cout<<1<<endl;
		}
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int f=1,a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-f;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a*f;
}
string s,st;
int len,re;
bool check()
{
	for(int t=0;t<len-1;++t){
		bool flag=0;
		for(int i=0;i<len/2-1;++i){
			if(st[i+t]!=st[len-i+t+1]){
				flag=1;
				break;
			}
		}
		if(flag)continue;
		for(int i=0;i<len;++i){
			if(st[i+t]!=s[i]){
				flag=1;
				break;
			}
		}
		if(flag){
			return 0;
		}
	}
	return 1;
}

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>s;
	len=s.length();
	bool flag=0;
	for(int i=1;i<len;++i){
		if(s[i]!=s[i-1]){
			flag=1;
			break;
		}
	}
	if(!flag){
		puts("impossible");
		return 0;
	}
	if(len&1){
		re=2;
	}else{
		st=s+s;
		if(check()){
//			puts("rerere");
			re=2;
		}else{
			re=1;
		}
	}
	cout<<re<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int f=1,a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-f;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a*f;
}
string s,st;
int len,re;

bool hw(string st)
{
	for(int i=0;i<st.length()/2;++i){
		int j=st.length()-i-1;
		if(st[i]!=st[j]){
			return 0;
		}
	}
	return 1;
}

bool check(string st)
{
	if(st.length()&1){
		return hw(st);
	}
	if(!hw(st)){
		return 0;
	}else{
		return check(st.substr(0,st.length()/2));
	}
}

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>s;
	len=s.length();
	bool flag=0;
	for(int i=1;i<len/2;++i){
		if(s[i]!=s[i-1]){
			flag=1;
			break;
		}
	}
	if(!flag){
		puts("Impossible");
		return 0;
	}
	if(len&1){
		re=2;
	}else{
		st=s;
		if(check(s)){
//			puts("rerere");
			re=2;
		}else{
			re=1;
		}
	}
	cout<<re<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int read()
{
	int f=1,a=0;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-'){
			f=-f;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		a=a*10+ch-'0';
		ch=getchar();
	}
	return a*f;
}
string s,st;
int len,re;
bool check()
{
	for(int t=0;t<len-1;++t){
		bool flag=0;
		for(int i=0;i<len/2-1;++i){
			if(st[i+t]!=st[len-i+t+1]){
				flag=1;
				break;
			}
		}
		if(flag)continue;
		for(int i=0;i<len;++i){
			if(st[i+t]!=s[i]){
				flag=1;
				break;
			}
		}
		if(flag){
			return 0;
		}
	}
	return 1;
}

int main()
{
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	cin>>s;
	len=s.length();
	bool flag=0;
	for(int i=1;i<len;++i){
		if(s[i]!=s[i-1]){
			flag=1;
			break;
		}
	}
	if(!flag){
		puts("Impossible");
		return 0;
	}
	if(len&1){
		re=2;
	}else{
		st=s+s;
		if(check()){
//			puts("rerere");
			re=2;
		}else{
			re=1;
		}
	}
	cout<<re<<endl;
	return 0;
}


/**
  * @brief codeforces
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 8192
#define P 0x2d4db75d
#define Q 0x13b0d50d
#define IQ 0x2646d9aa

char s[N];
int h[N];

bool check(int n)
{
    int t = -1;
    if(n&1) t = n/2;
    for(int i=1;i<n;++i)if(i!=t && s[i]!=s[0]) return true;
    return false;
}

int pow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans = (lli)ans*a%P;
        a = (lli)a*a%P;
        b>>=1;
    }
    return ans;
}

int main()
{
    int n = strlen(strtok(fgets(s,N,stdin)," \t\r\n"));
    if(!check(n)) return puts("Impossible"), 0;
    for(int i=1;i<=n;++i)h[i] = (h[i-1] + (lli)s[i-1]*pow(Q,i)) % P;
    int ans = 2;
    for(int i=1;i<n;++i)
    {
        int t = ((lli)h[i] * pow(Q,n-i) + ((lli)h[n]+P-h[i]) * pow(IQ,i)) % P;
        int it = ((lli)h[n-i] * pow(Q,i) + ((lli)h[n]+P-h[n-i]) * pow(IQ,n-i)) % P;
        if( t == it && t != h[n] )
        {
            ans = 1;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


/**
  * @brief codeforces
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 8192
#define P 0xf8315557
#define Q 0x5d72cd1
#define IQ 0xdffaf197

char s[N];
int h[N],ih[N];

bool check(int n)
{
    int t = -1;
    if(n&1) t = n/2;
    for(int i=1;i<n;++i)if(i!=t && s[i]!=s[0]) return true;
    return false;
}

int pow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans = (lli)ans*a%P;
        a = (lli)a*a%P;
        b>>=1;
    }
    return ans;
}

int main()
{
    int n = strlen(strtok(fgets(s,N,stdin)," \t\r\n"));
    if(!check(n)) return puts("Impossible"), 0;
    for(int i=1;i<=n;++i)h[i] = ((lli)h[i-1]*Q + s[i-1]) % P;
    for(int i=1;i<=n;++i)ih[i] = ((lli)ih[i-1]*Q + s[n-i]) % P;
    int ans = 2;
    for(int i=1;i<n;++i)
    {
        int t = ((lli)h[i] * pow(Q,n-i)+((lli)h[n]+P-h[i]) * pow(IQ,i)) % P;
        int it = ((lli)ih[n-i] * pow(Q,i)+((lli)ih[n]+P-ih[n-i]) * pow(IQ,n-i)) % P;
        if( t == it && t != h[n] )
        {
            ans = 1;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


/**
  * @brief codeforces
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 8192
#define P 0x2d4db75d
#define Q 0x13b0d50d
#define IQ 0x2646d9aa

char s[N];
int h[N],ih[N];

bool check(int n)
{
    int t = -1;
    if(n&1) t = n/2;
    for(int i=1;i<n;++i)if(i!=t && s[i]!=s[0]) return true;
    return false;
}

int pow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans = (lli)ans*a%P;
        a = (lli)a*a%P;
        b>>=1;
    }
    return ans;
}

int main()
{
    int n = strlen(strtok(fgets(s,N,stdin)," \t\r\n"));
    if(!check(n)) return puts("Impossible"), 0;
    for(int i=1;i<=n;++i)h[i] = ((lli)h[i-1]*Q + s[i-1]) % P;
    for(int i=1;i<=n;++i)ih[i] = ((lli)ih[i-1]*Q + s[n-i]) % P;
    int ans = 2;
    for(int i=1;i<n;++i)
    {
        int t = ((lli)h[i] * pow(Q,n-i)+((lli)h[n]+P-h[i]) * pow(IQ,i)) % P;
        int it = ((lli)ih[n-i] * pow(Q,i)+((lli)ih[n]+P-ih[n-i]) * pow(IQ,n-i)) % P;
        if( t == it && t != h[n] )
        {
            ans = 1;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


/**
  * @brief codeforces
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 8192
#define P 0xf8315557
#define Q 0x5d72cd1
#define IQ 0xdffaf197

char s[N];
int h[N],ih[N];

bool check(int n)
{
    for(int i=1;i<n;++i)if(s[i]!=s[0]) return true;
    return false;
}

int pow(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1) ans = (lli)ans*a%P;
        a = (lli)a*a%P;
        b>>=1;
    }
    return ans;
}

int main()
{
    int n = strlen(strtok(fgets(s,N,stdin)," \t\r\n"));
    if(!check(n)) return puts("Impossible"), 0;
    for(int i=1;i<=n;++i)h[i] = ((lli)h[i-1]*Q + s[i-1]) % P;
    for(int i=1;i<=n;++i)ih[i] = ((lli)ih[i-1]*Q + s[n-i]) % P;
    int ans = 2;
    for(int i=1;i<n;++i)
    {
        int t = ((lli)h[i] * pow(Q,n-i)+((lli)h[n]+P-h[i]) * pow(IQ,i)) % P;
        int it = ((lli)ih[n-i] * pow(Q,i)+((lli)ih[n]+P-ih[n-i]) * pow(IQ,n-i)) % P;
        if( t == it && t != h[n] )
        {
            ans = 1;
            break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
string s,t,o;
bool pan(string s){
	for(int i=0;i+i<s.length();i++)
		if(s[i]!=s[s.length()-i-1]) return 0;
	return 1;
}
int main()
{
	cin>>s; o=s;
	bool flg=0;
	for(int i=1;i<=s.length()/2-1;i++) flg|=(s[i]!=s[i-1]);
	if(!flg) return puts("Impossible"),0;
	for(int i=0;i<s.length()-1;i++){
		t+=*s.begin(),s.erase(s.begin());
		if((s+t)!=o&&pan(s+t)) return puts("1"),0;
	}
	puts("2");
}


#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
string s,t,o;
bool pan(string s){
	for(int i=0;i+i<s.length();i++)
		if(s[i]!=s[s.length()-i-1]) return 0;
	return 1;
}
int main()
{
	cin>>s; o=s;
	bool flg=0;
	for(int i=1;i<(s.length()-1)/2;i++) flg|=(s[i]!=s[i-1]);
	if(!flg) return puts("Impossible"),0;
	for(int i=0;i<s.length()-1;i++){
		t+=*s.begin(),s.erase(s.begin());
		if((s+t)!=o&&pan(s+t)) return puts("1"),0;
	}
	puts("2");
}


#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
string s,t;
bool pan(string s){
	for(int i=0;i+i<s.length();i++)
		if(s[i]!=s[s.length()-i-1]) return 0;
	return 1;
}
int main()
{
	cin>>s;
	bool flg=0;
	for(int i=1;i<s.length();i++) flg|=(s[i]!=s[i-1]);
	if(!flg) return puts("Impossible"),0;
	for(int i=0;i<s.length()-1;i++){
		t+=*s.begin(),s.erase(s.begin());
		if(pan(s+t)) return puts("1"),0;
	}
	puts("2");
}


#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
string s;
bool pan(string s){
	int n=s.length();
	for(int i=0;i+i<n;i++)
		if(s[i]!=s[n-i-1]) return 0;
	return 1;
}
int main()
{
	cin>>s; int n=s.length();
	bool flg=0;
	for(int i=1;i<=n/2-1;i++) flg|=(s[i]!=s[i-1]);
	if(!flg) return puts("Impossible"),0;
	for(int i=1;i<n;i++){
		string p = s.substr(i,n-i) + s.substr(0,i);
		if(p!=s&&pan(p)) return puts("1"),0;
	}
	puts("2");
}


#include <bits/stdc++.h>
#define maxn 300005
using namespace std;
string s,t,o;
bool pan(string s){
	for(int i=0;i+i<s.length();i++)
		if(s[i]!=s[s.length()-i-1]) return 0;
	return 1;
}
int main()
{
	cin>>s; o=s;
	bool flg=0;
	for(int i=1;i<s.length();i++) flg|=(s[i]!=s[i-1]);
	if(!flg) return puts("Impossible"),0;
	for(int i=0;i<s.length()-1;i++){
		t+=*s.begin(),s.erase(s.begin());
		if((s+t)!=o&&pan(s+t)) return puts("1"),0;
	}
	puts("2");
}


//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define si(x) scanf("%d",&x)
#define sii(a,b) scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define siiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sl(x) scanf("%I64d",&x)
#define sll(a,b) scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define ss(x) scanf("%s",x+1)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(a,b,c) printf("%d %d %d",a,b,c)
#define piiii(a,b,c,d) printf("%d %d %d %d",a,b,c,d)
#define Pi(x) printf("%d\n",x)
#define Pii(x,y) printf("%d %d\n",x,y)
#define Piii(a,b,c) printf("%d %d %d\n",a,b,c)
#define Piiii(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define pl(x) printf("%I64d",x)
#define pll(x,y) printf("%I64d %I64d",x,y)
#define plll(a,b,c) printf("%I64d %I64d %I64d",a,b,c)
#define pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d",a,b,c,d)
#define Pl(x) printf("%I64d\n",x)
#define Pll(x,y) printf("%I64d %I64d\n",x,y)
#define Plll(a,b,c) printf("%I64d %I64d %I64d\n",a,b,c)
#define Pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d\n",a,b,c,d)
#define ps(x) printf("%s",x+1)
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;typedef long long LL;typedef long double LD;const LL pp=1e9+7;const LD eps=1e-8;
inline LL ksm(LL x,LL y=pp-2){x=(x%pp+pp)%pp;LL ans=1;while (y){if (y&1) ans=ans*x%pp;x=x*x%pp;y>>=1;}return ans;}
inline LL gcd(LL x,LL y){return y?gcd(y,x%y):x;}
inline void reads(char s[],int &n){n=0;char ch=getchar();while (ch==' ' || ch=='\n' || ch=='\r') ch=getchar();
while (ch!=' ' && ch!='\n' && ch!='\r' && ch!=EOF) s[++n]=ch,ch=getchar();}

// HEAP Attention : Int + Array_Size + Stores In key[] + Top.id/v = Min
// init() empty() top() push(id,value) pop()
/*
struct HEAP
{
    int sz;
    struct HEAP_Pair{int id,v;}T[100009];
    inline int ls(int x){return x<<1;}
    inline int rs(int x){return ((x<<1)|1);}
    inline int f(int x){return x>>1;}
    inline void init(){sz=0;}
    inline bool empty(){return sz==0;}
    inline HEAP_Pair top(){return T[1];}
    inline void push(int x,int v)
    {
        T[++sz].id=x;
        T[sz].v=v;
        pushup(sz);
    }
    inline void pop()
    {
        T[1]=T[sz--];
        pushdown(1);
    }
    void pushup(int x)
    {
        if (x==1) return;
        if (T[x].v<T[f(x)].v)    //
        {
            HEAP_Pair tmp=T[f(x)];
            T[f(x)]=T[x];
            T[x]=tmp;
            pushup(f(x));
        }
    }
    void pushdown(int x)
    {
        if (ls(x)>sz) return;
        int t=ls(x);
        if (rs(x)<=sz)
            if (T[rs(x)].v<T[t].v) t=rs(x);   //
        if (T[t].v<T[x].v)   //
        {
            HEAP_Pair tmp=T[t];
            T[t]=T[x];
            T[x]=tmp;
            pushdown(t);
        }
    }
};*/

// BIT Attention : Bit.init(Size) + Int + Array_Size + [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
// init(Size) [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
/*
struct BIT
{
	int T[100009],sz;
	inline int lowbit(int x){return x&(-x);}
	inline void init(int x){sz=x;}
	inline void Badd(int x,int v)
	{
		while (x<=sz)
		{
			T[x]+=v;
			x+=lowbit(x);
		}
	}
	inline int Bsum(int x)
	{
		int ans=0;
		while (x>=1)
		{
			ans+=T[x];
			x-=lowbit(x);
		}
		return ans;
	}
	inline void add1(int x,int v){Badd(x,v);}
	inline int sum(int l,int r){if (l>r) return 0;return Bsum(r)-Bsum(l-1);}
	inline void add(int l,int r,int v){Badd(l,v);Badd(r+1,-v);}
	inline int get(int x){return Bsum(x);}
};
*/

//Min/Max Pri Que Attention : MPQ.init(Size,Type [0=Min;1=Max] ) + get().id/v/t + Int + Array_Size
//get().id/v/t push(id,value,time) init(Size,Type) upd(L,R) empty()
/*
struct MPQ
{
	int sz,l,r,type;
	struct MPQ_Pair{int id,v,t;}q[1000009];
	inline void init(int thesz,int thetype){sz=thesz;l=r=0;type=thetype;}
	inline bool empty(){return l==r;}
	inline int pre(int x){if (x-1<0) return sz;return x-1;}
	inline int suc(int x){if (x+1>sz) return 1;return x+1;}
	inline void push(int id,int v,int t)
	{
		if (!type)
			while (q[pre(r)].v>=v && !empty()) r=pre(r);
		else
			while (q[pre(r)].v<=v && !empty()) r=pre(r);
		q[r].id=id,q[r].v=v,q[r].t=t;
		r=suc(r);
	}
	inline MPQ_Pair get(){return q[l];}
	inline void upd(int tL,int tR){while ((q[l].t<tL || q[l].t>tR) && !empty()) l=suc(l);}
};
*/
//========================    C    ========================    F    ==================================
int n;
char S[5009],T[5009];
int cnt[1009];
void test()
{
	for (int i=1;i<n;i++)
	{
		for (int j=i+1;j<=n;j++)
			T[j-i]=S[j];
		for (int j=1;j<=i;j++)
			T[j+n-i]=S[j];
		bool ok=1;
		for (int j=1;j<=n;j++)
			if (T[j]!=T[n-j+1])
			{
				ok=0;
				break;
			}
		if (ok)
		{
			puts("1");
			exit(0);
		}
	}
	puts("2");
}
int main()
{
	//freopen("r.txt","r",stdin);
	//freopen("w1.txt","w",stdout);
	reads(S,n);
	for (int i=1;i<=n;i++)
		cnt[S[i]]++;
	if (!(n&1))
	{
			if (cnt[S[n]]==n)
			puts("Impossible");
			else test();
	}
	else
	{
			if (cnt[S[n]]>=n-1)
			puts("Impossible");
			else test();
	}
	return 0;
}


//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define si(x) scanf("%d",&x)
#define sii(a,b) scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define siiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sl(x) scanf("%I64d",&x)
#define sll(a,b) scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define ss(x) scanf("%s",x+1)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(a,b,c) printf("%d %d %d",a,b,c)
#define piiii(a,b,c,d) printf("%d %d %d %d",a,b,c,d)
#define Pi(x) printf("%d\n",x)
#define Pii(x,y) printf("%d %d\n",x,y)
#define Piii(a,b,c) printf("%d %d %d\n",a,b,c)
#define Piiii(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define pl(x) printf("%I64d",x)
#define pll(x,y) printf("%I64d %I64d",x,y)
#define plll(a,b,c) printf("%I64d %I64d %I64d",a,b,c)
#define pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d",a,b,c,d)
#define Pl(x) printf("%I64d\n",x)
#define Pll(x,y) printf("%I64d %I64d\n",x,y)
#define Plll(a,b,c) printf("%I64d %I64d %I64d\n",a,b,c)
#define Pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d\n",a,b,c,d)
#define ps(x) printf("%s",x+1)
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;typedef long long LL;typedef long double LD;const LL pp=1e9+7;const LD eps=1e-8;
inline LL ksm(LL x,LL y=pp-2){x=(x%pp+pp)%pp;LL ans=1;while (y){if (y&1) ans=ans*x%pp;x=x*x%pp;y>>=1;}return ans;}
inline LL gcd(LL x,LL y){return y?gcd(y,x%y):x;}
inline void reads(char s[],int &n){n=0;char ch=getchar();while (ch==' ' || ch=='\n' || ch=='\r') ch=getchar();
while (ch!=' ' && ch!='\n' && ch!='\r' && ch!=EOF) s[++n]=ch,ch=getchar();}

// HEAP Attention : Int + Array_Size + Stores In key[] + Top.id/v = Min
// init() empty() top() push(id,value) pop()
/*
struct HEAP
{
    int sz;
    struct HEAP_Pair{int id,v;}T[100009];
    inline int ls(int x){return x<<1;}
    inline int rs(int x){return ((x<<1)|1);}
    inline int f(int x){return x>>1;}
    inline void init(){sz=0;}
    inline bool empty(){return sz==0;}
    inline HEAP_Pair top(){return T[1];}
    inline void push(int x,int v)
    {
        T[++sz].id=x;
        T[sz].v=v;
        pushup(sz);
    }
    inline void pop()
    {
        T[1]=T[sz--];
        pushdown(1);
    }
    void pushup(int x)
    {
        if (x==1) return;
        if (T[x].v<T[f(x)].v)    //
        {
            HEAP_Pair tmp=T[f(x)];
            T[f(x)]=T[x];
            T[x]=tmp;
            pushup(f(x));
        }
    }
    void pushdown(int x)
    {
        if (ls(x)>sz) return;
        int t=ls(x);
        if (rs(x)<=sz)
            if (T[rs(x)].v<T[t].v) t=rs(x);   //
        if (T[t].v<T[x].v)   //
        {
            HEAP_Pair tmp=T[t];
            T[t]=T[x];
            T[x]=tmp;
            pushdown(t);
        }
    }
};*/

// BIT Attention : Bit.init(Size) + Int + Array_Size + [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
// init(Size) [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
/*
struct BIT
{
	int T[100009],sz;
	inline int lowbit(int x){return x&(-x);}
	inline void init(int x){sz=x;}
	inline void Badd(int x,int v)
	{
		while (x<=sz)
		{
			T[x]+=v;
			x+=lowbit(x);
		}
	}
	inline int Bsum(int x)
	{
		int ans=0;
		while (x>=1)
		{
			ans+=T[x];
			x-=lowbit(x);
		}
		return ans;
	}
	inline void add1(int x,int v){Badd(x,v);}
	inline int sum(int l,int r){if (l>r) return 0;return Bsum(r)-Bsum(l-1);}
	inline void add(int l,int r,int v){Badd(l,v);Badd(r+1,-v);}
	inline int get(int x){return Bsum(x);}
};
*/

//Min/Max Pri Que Attention : MPQ.init(Size,Type [0=Min;1=Max] ) + get().id/v/t + Int + Array_Size
//get().id/v/t push(id,value,time) init(Size,Type) upd(L,R) empty()
/*
struct MPQ
{
	int sz,l,r,type;
	struct MPQ_Pair{int id,v,t;}q[1000009];
	inline void init(int thesz,int thetype){sz=thesz;l=r=0;type=thetype;}
	inline bool empty(){return l==r;}
	inline int pre(int x){if (x-1<0) return sz;return x-1;}
	inline int suc(int x){if (x+1>sz) return 1;return x+1;}
	inline void push(int id,int v,int t)
	{
		if (!type)
			while (q[pre(r)].v>=v && !empty()) r=pre(r);
		else
			while (q[pre(r)].v<=v && !empty()) r=pre(r);
		q[r].id=id,q[r].v=v,q[r].t=t;
		r=suc(r);
	}
	inline MPQ_Pair get(){return q[l];}
	inline void upd(int tL,int tR){while ((q[l].t<tL || q[l].t>tR) && !empty()) l=suc(l);}
};
*/
//========================    C    ========================    F    ==================================
int n;
char S[5009];
int cnt[1009];
int main()
{
	//freopen("r.txt","r",stdin);
	//freopen("w1.txt","w",stdout);
	reads(S,n);
	for (int i=1;i<=n;i++)
		cnt[S[i]]++;
	if (cnt[S[n]]==n || (cnt[S[n]]==n-1 && n&1))
	{
		puts("Impossible");
		return 0;
	}
	else if (n&1)
	{
		puts("2");
	}
	else
		puts("1");
	return 0;
}


//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define si(x) scanf("%d",&x)
#define sii(a,b) scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define siiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sl(x) scanf("%I64d",&x)
#define sll(a,b) scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define ss(x) scanf("%s",x+1)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(a,b,c) printf("%d %d %d",a,b,c)
#define piiii(a,b,c,d) printf("%d %d %d %d",a,b,c,d)
#define Pi(x) printf("%d\n",x)
#define Pii(x,y) printf("%d %d\n",x,y)
#define Piii(a,b,c) printf("%d %d %d\n",a,b,c)
#define Piiii(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define pl(x) printf("%I64d",x)
#define pll(x,y) printf("%I64d %I64d",x,y)
#define plll(a,b,c) printf("%I64d %I64d %I64d",a,b,c)
#define pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d",a,b,c,d)
#define Pl(x) printf("%I64d\n",x)
#define Pll(x,y) printf("%I64d %I64d\n",x,y)
#define Plll(a,b,c) printf("%I64d %I64d %I64d\n",a,b,c)
#define Pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d\n",a,b,c,d)
#define ps(x) printf("%s",x+1)
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;typedef long long LL;typedef long double LD;const LL pp=1e9+7;const LD eps=1e-8;
inline LL ksm(LL x,LL y=pp-2){x=(x%pp+pp)%pp;LL ans=1;while (y){if (y&1) ans=ans*x%pp;x=x*x%pp;y>>=1;}return ans;}
inline LL gcd(LL x,LL y){return y?gcd(y,x%y):x;}
inline void reads(char s[],int &n){n=0;char ch=getchar();while (ch==' ' || ch=='\n' || ch=='\r') ch=getchar();
while (ch!=' ' && ch!='\n' && ch!='\r' && ch!=EOF) s[++n]=ch,ch=getchar();}

// HEAP Attention : Int + Array_Size + Stores In key[] + Top.id/v = Min
// init() empty() top() push(id,value) pop()
/*
struct HEAP
{
    int sz;
    struct HEAP_Pair{int id,v;}T[100009];
    inline int ls(int x){return x<<1;}
    inline int rs(int x){return ((x<<1)|1);}
    inline int f(int x){return x>>1;}
    inline void init(){sz=0;}
    inline bool empty(){return sz==0;}
    inline HEAP_Pair top(){return T[1];}
    inline void push(int x,int v)
    {
        T[++sz].id=x;
        T[sz].v=v;
        pushup(sz);
    }
    inline void pop()
    {
        T[1]=T[sz--];
        pushdown(1);
    }
    void pushup(int x)
    {
        if (x==1) return;
        if (T[x].v<T[f(x)].v)    //
        {
            HEAP_Pair tmp=T[f(x)];
            T[f(x)]=T[x];
            T[x]=tmp;
            pushup(f(x));
        }
    }
    void pushdown(int x)
    {
        if (ls(x)>sz) return;
        int t=ls(x);
        if (rs(x)<=sz)
            if (T[rs(x)].v<T[t].v) t=rs(x);   //
        if (T[t].v<T[x].v)   //
        {
            HEAP_Pair tmp=T[t];
            T[t]=T[x];
            T[x]=tmp;
            pushdown(t);
        }
    }
};*/

// BIT Attention : Bit.init(Size) + Int + Array_Size + [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
// init(Size) [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
/*
struct BIT
{
	int T[100009],sz;
	inline int lowbit(int x){return x&(-x);}
	inline void init(int x){sz=x;}
	inline void Badd(int x,int v)
	{
		while (x<=sz)
		{
			T[x]+=v;
			x+=lowbit(x);
		}
	}
	inline int Bsum(int x)
	{
		int ans=0;
		while (x>=1)
		{
			ans+=T[x];
			x-=lowbit(x);
		}
		return ans;
	}
	inline void add1(int x,int v){Badd(x,v);}
	inline int sum(int l,int r){if (l>r) return 0;return Bsum(r)-Bsum(l-1);}
	inline void add(int l,int r,int v){Badd(l,v);Badd(r+1,-v);}
	inline int get(int x){return Bsum(x);}
};
*/

//Min/Max Pri Que Attention : MPQ.init(Size,Type [0=Min;1=Max] ) + get().id/v/t + Int + Array_Size
//get().id/v/t push(id,value,time) init(Size,Type) upd(L,R) empty()
/*
struct MPQ
{
	int sz,l,r,type;
	struct MPQ_Pair{int id,v,t;}q[1000009];
	inline void init(int thesz,int thetype){sz=thesz;l=r=0;type=thetype;}
	inline bool empty(){return l==r;}
	inline int pre(int x){if (x-1<0) return sz;return x-1;}
	inline int suc(int x){if (x+1>sz) return 1;return x+1;}
	inline void push(int id,int v,int t)
	{
		if (!type)
			while (q[pre(r)].v>=v && !empty()) r=pre(r);
		else
			while (q[pre(r)].v<=v && !empty()) r=pre(r);
		q[r].id=id,q[r].v=v,q[r].t=t;
		r=suc(r);
	}
	inline MPQ_Pair get(){return q[l];}
	inline void upd(int tL,int tR){while ((q[l].t<tL || q[l].t>tR) && !empty()) l=suc(l);}
};
*/
//========================    C    ========================    F    ==================================
int n;
char S[5009],T[5009];
int cnt[1009];
void test()
{
	for (int i=1;i<n;i++)
	{
		for (int j=i+1;j<=n;j++)
			T[j-i]=S[j];
		for (int j=1;j<=i;j++)
			T[j+n-i]=S[j];
		bool ok=1;
		for (int j=1;j<=n;j++)
			if (T[j]!=T[n-j+1])
			{
				ok=0;
				break;
			}
		if (!ok) continue;
		ok=0;
		for (int j=1;j<=n;j++)
			if (T[j]!=S[j])
			{
				ok=1;
				break;
			}
		if (ok)
		{
			puts("1");
			exit(0);
		}
	}
	puts("2");
}
int main()
{
	freopen("r.txt","r",stdin);
	freopen("w1.txt","w",stdout);
	reads(S,n);
	for (int i=1;i<=n;i++)
		cnt[S[i]]++;
	if (!(n&1))
	{
			if (cnt[S[n]]==n)
			puts("Impossible");
			else test();
	}
	else
	{
			if (cnt[S[n]]>=n-1)
			puts("Impossible");
			else test();
	}
	return 0;
}


//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define si(x) scanf("%d",&x)
#define sii(a,b) scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define siiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define sl(x) scanf("%I64d",&x)
#define sll(a,b) scanf("%I64d%I64d",&a,&b)
#define slll(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d)
#define ss(x) scanf("%s",x+1)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define piii(a,b,c) printf("%d %d %d",a,b,c)
#define piiii(a,b,c,d) printf("%d %d %d %d",a,b,c,d)
#define Pi(x) printf("%d\n",x)
#define Pii(x,y) printf("%d %d\n",x,y)
#define Piii(a,b,c) printf("%d %d %d\n",a,b,c)
#define Piiii(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define pl(x) printf("%I64d",x)
#define pll(x,y) printf("%I64d %I64d",x,y)
#define plll(a,b,c) printf("%I64d %I64d %I64d",a,b,c)
#define pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d",a,b,c,d)
#define Pl(x) printf("%I64d\n",x)
#define Pll(x,y) printf("%I64d %I64d\n",x,y)
#define Plll(a,b,c) printf("%I64d %I64d %I64d\n",a,b,c)
#define Pllll(a,b,c,d) printf("%I64d %I64d %I64d %I64d\n",a,b,c,d)
#define ps(x) printf("%s",x+1)
#define space putchar(' ')
#define enter putchar('\n')
using namespace std;typedef long long LL;typedef long double LD;const LL pp=1e9+7;const LD eps=1e-8;
inline LL ksm(LL x,LL y=pp-2){x=(x%pp+pp)%pp;LL ans=1;while (y){if (y&1) ans=ans*x%pp;x=x*x%pp;y>>=1;}return ans;}
inline LL gcd(LL x,LL y){return y?gcd(y,x%y):x;}
inline void reads(char s[],int &n){n=0;char ch=getchar();while (ch==' ' || ch=='\n' || ch=='\r') ch=getchar();
while (ch!=' ' && ch!='\n' && ch!='\r' && ch!=EOF) s[++n]=ch,ch=getchar();}

// HEAP Attention : Int + Array_Size + Stores In key[] + Top.id/v = Min
// init() empty() top() push(id,value) pop()
/*
struct HEAP
{
    int sz;
    struct HEAP_Pair{int id,v;}T[100009];
    inline int ls(int x){return x<<1;}
    inline int rs(int x){return ((x<<1)|1);}
    inline int f(int x){return x>>1;}
    inline void init(){sz=0;}
    inline bool empty(){return sz==0;}
    inline HEAP_Pair top(){return T[1];}
    inline void push(int x,int v)
    {
        T[++sz].id=x;
        T[sz].v=v;
        pushup(sz);
    }
    inline void pop()
    {
        T[1]=T[sz--];
        pushdown(1);
    }
    void pushup(int x)
    {
        if (x==1) return;
        if (T[x].v<T[f(x)].v)    //
        {
            HEAP_Pair tmp=T[f(x)];
            T[f(x)]=T[x];
            T[x]=tmp;
            pushup(f(x));
        }
    }
    void pushdown(int x)
    {
        if (ls(x)>sz) return;
        int t=ls(x);
        if (rs(x)<=sz)
            if (T[rs(x)].v<T[t].v) t=rs(x);   //
        if (T[t].v<T[x].v)   //
        {
            HEAP_Pair tmp=T[t];
            T[t]=T[x];
            T[x]=tmp;
            pushdown(t);
        }
    }
};*/

// BIT Attention : Bit.init(Size) + Int + Array_Size + [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
// init(Size) [ add1(x,v) sum(l,r) ] Or [ add(l,r,v) get(x) ]
/*
struct BIT
{
	int T[100009],sz;
	inline int lowbit(int x){return x&(-x);}
	inline void init(int x){sz=x;}
	inline void Badd(int x,int v)
	{
		while (x<=sz)
		{
			T[x]+=v;
			x+=lowbit(x);
		}
	}
	inline int Bsum(int x)
	{
		int ans=0;
		while (x>=1)
		{
			ans+=T[x];
			x-=lowbit(x);
		}
		return ans;
	}
	inline void add1(int x,int v){Badd(x,v);}
	inline int sum(int l,int r){if (l>r) return 0;return Bsum(r)-Bsum(l-1);}
	inline void add(int l,int r,int v){Badd(l,v);Badd(r+1,-v);}
	inline int get(int x){return Bsum(x);}
};
*/

//Min/Max Pri Que Attention : MPQ.init(Size,Type [0=Min;1=Max] ) + get().id/v/t + Int + Array_Size
//get().id/v/t push(id,value,time) init(Size,Type) upd(L,R) empty()
/*
struct MPQ
{
	int sz,l,r,type;
	struct MPQ_Pair{int id,v,t;}q[1000009];
	inline void init(int thesz,int thetype){sz=thesz;l=r=0;type=thetype;}
	inline bool empty(){return l==r;}
	inline int pre(int x){if (x-1<0) return sz;return x-1;}
	inline int suc(int x){if (x+1>sz) return 1;return x+1;}
	inline void push(int id,int v,int t)
	{
		if (!type)
			while (q[pre(r)].v>=v && !empty()) r=pre(r);
		else
			while (q[pre(r)].v<=v && !empty()) r=pre(r);
		q[r].id=id,q[r].v=v,q[r].t=t;
		r=suc(r);
	}
	inline MPQ_Pair get(){return q[l];}
	inline void upd(int tL,int tR){while ((q[l].t<tL || q[l].t>tR) && !empty()) l=suc(l);}
};
*/
//========================    C    ========================    F    ==================================
int n;
char S[5009],T[5009];
int cnt[1009];
void test()
{
	for (int i=1;i<n;i++)
	{
		for (int j=i+1;j<=n;j++)
			T[j-i]=S[j];
		for (int j=1;j<=i;j++)
			T[j+n-i]=S[j];
		bool ok=1;
		for (int j=1;j<=n;j++)
			if (T[j]!=T[n-j+1])
			{
				ok=0;
				break;
			}
		if (!ok) continue;
		ok=0;
		for (int j=1;j<=n;j++)
			if (T[j]!=S[j])
			{
				ok=1;
				break;
			}
		if (ok)
		{
			puts("1");
			exit(0);
		}
	}
	puts("2");
}
int main()
{
	//freopen("r.txt","r",stdin);
	//freopen("w1.txt","w",stdout);
	reads(S,n);
	for (int i=1;i<=n;i++)
		cnt[S[i]]++;
	if (!(n&1))
	{
			if (cnt[S[n]]==n)
			puts("Impossible");
			else test();
	}
	else
	{
			if (cnt[S[n]]>=n-1)
			puts("Impossible");
			else test();
	}
	return 0;
}