import java.io.BufferedReader;
import java.io.InputStreamReader;


public class ReplaceToMakeRegularBracketSequence {

	/**
	 * @param args
	 */
	public static void main(String[] args)throws Exception {
		// TODO Auto-generated method stub

				BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
				char[] cc = br.readLine().toCharArray();
				int n = cc.length;
				char[] stack = new char[n];
				int k = 0, cnt = 0;
				for (int i = 0; i < n; i++) {
					char q = cc[i];
					if (q == '>' || q == '}' || q == ']' || q == ')') {
						if (k == 0) {
							System.out.println("Impossible");
							return;
						}
						char p = stack[--k];
						if ((p == '<' && q == '>' || p == '{' && q == '}' || p == '[' && q == ']' || p == '(' && q == ')'))
						{}
						else
							cnt++;
					} else
						stack[k++] = q;
				}
				if(k>0)
					System.out.println("Inpossible");
				else
					System.out.println(cnt);
			}
		}

	
