JerryL/AlgoSimBench huggingface dataset:
378_C. Maze

Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.

Pavel drew a grid maze with all empty cells forming a connected area. That is, you can go from any empty cell to any other one. Pavel doesn't like it when his maze has too little walls. He wants to turn exactly k empty cells into walls so that all the remaining cells still formed a connected area. Help him.

Input

The first line contains three integers n, m, k (1 ≤ n, m ≤ 500, 0 ≤ k < s), where n and m are the maze's height and width, correspondingly, k is the number of walls Pavel wants to add and letter s represents the number of empty cells in the original maze.

Each of the next n lines contains m characters. They describe the original maze. If a character on a line equals ".", then the corresponding cell is empty and if the character equals "#", then the cell is a wall.

Output

Print n lines containing m characters each: the new maze that fits Pavel's requirements. Mark the empty cells that you transformed into walls as "X", the other cells must be left without changes (that is, "." and "#").

It is guaranteed that a solution exists. If there are multiple solutions you can output any of them.

Examples

Input

3 4 2
#..#
..#.
#...


Output

#.X#
X.#.
#...


Input

5 4 5
#...
#.#.
.#..
...#
.#.#


Output

#XXX
#X#.
X#..
...#
.#.#

Example input:
3 4 2
#..#
..#.
#...

5 4 5
#...
#.#.
.#..
...#
.#.#


Example output:
#..#
..#X
#..X

#...
#.#.
X#..
XX.#
X#X#


Tags: dfs and similar
Difficulty rating: 1600

Solution:
#include <bits/stdc++.h>
using namespace std;
char mp[512][512];
bool vis[512][512];
int n, m, k;
void dfs(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) return;
  if (mp[x][y] != '.') return;
  if (vis[x][y]) return;
  vis[x][y] = true;
  dfs(x + 1, y);
  dfs(x - 1, y);
  dfs(x, y + 1);
  dfs(x, y - 1);
  if (k) mp[x][y] = 'X', k--;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%s", mp[i]);
  for (int i = 0; i < n && k; i++) {
    for (int j = 0; j < m && k; j++) {
      dfs(i, j);
    }
  }
  for (int i = 0; i < n; i++) puts(mp[i]);
  return 0;
}
392_C. Yet Another Number Sequence

Everyone knows what the Fibonacci sequence is. This sequence can be defined by the recurrence relation: 

F1 = 1, F2 = 2, Fi = Fi - 1 + Fi - 2 (i > 2).

We'll define a new number sequence Ai(k) by the formula: 

Ai(k) = Fi × ik (i ≥ 1).

In this problem, your task is to calculate the following sum: A1(k) + A2(k) + ... + An(k). The answer can be very large, so print it modulo 1000000007 (109 + 7).

Input

The first line contains two space-separated integers n, k (1 ≤ n ≤ 1017; 1 ≤ k ≤ 40).

Output

Print a single integer — the sum of the first n elements of the sequence Ai(k) modulo 1000000007 (109 + 7).

Examples

Input

1 1


Output

1


Input

4 1


Output

34


Input

5 2


Output

316


Input

7 4


Output

73825

Example input:
7 4

5 2

1 1

4 1


Example output:
73825
316
1
34

Tags: combinatorics
math
matrices
Difficulty rating: 0

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 90, mod = 1e9 + 7;
long long n;
int m, k, ans, C[N][N];
struct mat {
  int a[N][N];
} R, T;
mat mul(mat a, mat b) {
  mat c;
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= m; j++) c.a[i][j] = 0;
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k <= m; k++)
        c.a[i][j] = (c.a[i][j] + 1ll * a.a[i][k] * b.a[k][j] % mod) % mod;
  return c;
}
int main() {
  scanf("%lld%d", &n, &k);
  m = k * 2 + 2;
  for (int i = 0; i <= k; i++) C[i][0] = 1;
  for (int i = 1; i <= k; i++)
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= i; j++)
      T.a[i][j] = T.a[i][j + k + 1] = T.a[i + k + 1][j] = C[i][j];
  T.a[m][k] = T.a[m][m] = 1;
  for (int i = 0; i <= m; i++) R.a[i][i] = 1;
  for (; n; n >>= 1, T = mul(T, T))
    if (n & 1) R = mul(R, T);
  for (int i = 0; i < m; i++) (ans += R.a[m][i]) %= mod;
  printf("%d\n", ans);
  return 0;
}
442_B. Andrey and Problem

Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help. He can ask some of them to come up with a contest problem. Andrey knows one value for each of his fiends — the probability that this friend will come up with a problem if Andrey asks him.

Help Andrey choose people to ask. As he needs only one problem, Andrey is going to be really upset if no one comes up with a problem or if he gets more than one problem from his friends. You need to choose such a set of people that maximizes the chances of Andrey not getting upset.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of Andrey's friends. The second line contains n real numbers pi (0.0 ≤ pi ≤ 1.0) — the probability that the i-th friend can come up with a problem. The probabilities are given with at most 6 digits after decimal point.

Output

Print a single real number — the probability that Andrey won't get upset at the optimal choice of friends. The answer will be considered valid if it differs from the correct one by at most 10 - 9.

Examples

Input

4
0.1 0.2 0.3 0.8


Output

0.800000000000


Input

2
0.1 0.2


Output

0.260000000000

Note

In the first sample the best strategy for Andrey is to ask only one of his friends, the most reliable one.

In the second sample the best strategy for Andrey is to ask all of his friends to come up with a problem. Then the probability that he will get exactly one problem is 0.1·0.8 + 0.9·0.2 = 0.26.

Example input:
2
0.1 0.2

4
0.1 0.2 0.3 0.8


Example output:
0.2600000000

0.8000000000


Tags: greedy
math
probabilities
Difficulty rating: 1800

Solution:
input()
a,b,c=1,0,0
for p in sorted(map(float,raw_input().split()))[::-1]:
  b=b*(1-p)+a*p
  a*=1-p
  c=max(c,b)
print c
453_B. Little Pony and Harmony Chest

Princess Twilight went to Celestia and Luna's old castle to research the chest from the Elements of Harmony.

<image>

A sequence of positive integers bi is harmony if and only if for every two elements of the sequence their greatest common divisor equals 1. According to an ancient book, the key of the chest is a harmony sequence bi which minimizes the following expression:

<image>

You are given sequence ai, help Princess Twilight to find the key.

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of elements of the sequences a and b. The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 30).

Output

Output the key — sequence bi that minimizes the sum described above. If there are multiple optimal sequences, you can output any of them.

Examples

Input

5
1 1 1 1 1


Output

1 1 1 1 1 

Input

5
1 6 4 2 8


Output

1 5 3 1 8 

Example input:
5
1 6 4 2 8

5
1 1 1 1 1


Example output:
1 5 3 1 8 

1 1 1 1 1 


Tags: bitmasks
brute force
dp
Difficulty rating: 2000

Solution:
#include <bits/stdc++.h>
int N;
int prm[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59};
int dn[105][(1 << 17) + 3];
int tut[105][(1 << 17) + 3];
int d[105], sy[65];
int f(int k, int fl) {
  if (k == N) return 0;
  if (dn[k][fl] != -1) return dn[k][fl];
  int ret = 1000000;
  for (int i = 1; i < 61; i++) {
    if ((sy[i] & fl) == 0) {
      if (ret > f(k + 1, fl | sy[i]) + abs(d[k] - i)) {
        ret = f(k + 1, fl | sy[i]) + abs(d[k] - i);
        tut[k][fl] = i;
      }
    }
  }
  return dn[k][fl] = ret;
}
int main() {
  memset(dn, -1, sizeof(dn));
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) scanf("%d", &d[i]);
  for (int i = 2; i <= 60; i++)
    for (int j = 0; j < 17; j++) {
      if (i % prm[j] == 0) sy[i] |= 1 << j;
    }
  f(0, 0);
  int yon = 0;
  for (int i = 0; i < N; i++) {
    printf("%d ", tut[i][yon]);
    yon |= sy[tut[i][yon]];
  }
  return 0;
}
505_C. Mr. Kitayuta, the Treasure Hunter

The Shuseki Islands are an archipelago of 30001 small islands in the Yutampo Sea. The islands are evenly spaced along a line, numbered from 0 to 30000 from the west to the east. These islands are known to contain many treasures. There are n gems in the Shuseki Islands in total, and the i-th gem is located on island pi.

Mr. Kitayuta has just arrived at island 0. With his great jumping ability, he will repeatedly perform jumps between islands to the east according to the following process: 

  * First, he will jump from island 0 to island d. 
  * After that, he will continue jumping according to the following rule. Let l be the length of the previous jump, that is, if his previous jump was from island prev to island cur, let l = cur - prev. He will perform a jump of length l - 1, l or l + 1 to the east. That is, he will jump to island (cur + l - 1), (cur + l) or (cur + l + 1) (if they exist). The length of a jump must be positive, that is, he cannot perform a jump of length 0 when l = 1. If there is no valid destination, he will stop jumping. 



Mr. Kitayuta will collect the gems on the islands visited during the process. Find the maximum number of gems that he can collect.

Input

The first line of the input contains two space-separated integers n and d (1 ≤ n, d ≤ 30000), denoting the number of the gems in the Shuseki Islands and the length of the Mr. Kitayuta's first jump, respectively.

The next n lines describe the location of the gems. The i-th of them (1 ≤ i ≤ n) contains a integer pi (d ≤ p1 ≤ p2 ≤ ... ≤ pn ≤ 30000), denoting the number of the island that contains the i-th gem.

Output

Print the maximum number of gems that Mr. Kitayuta can collect.

Examples

Input

4 10
10
21
27
27


Output

3


Input

8 8
9
19
28
36
45
55
66
78


Output

6


Input

13 7
8
8
9
16
17
17
18
21
23
24
24
26
30


Output

4

Note

In the first sample, the optimal route is 0  →  10 (+1 gem)  →  19  →  27 (+2 gems)  → ...

In the second sample, the optimal route is 0  →  8  →  15  →  21 →  28 (+1 gem)  →  36 (+1 gem)  →  45 (+1 gem)  →  55 (+1 gem)  →  66 (+1 gem)  →  78 (+1 gem)  → ...

In the third sample, the optimal route is 0  →  7  →  13  →  18 (+1 gem)  →  24 (+2 gems)  →  30 (+1 gem)  → ...

Example input:
4 10
10
21
27
27

8 8
9
19
28
36
45
55
66
78

13 7
8
8
9
16
17
17
18
21
23
24
24
26
30


Example output:
3

6

4


Tags: dfs and similar
dp
two pointers
Difficulty rating: 1900

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, k, o[30110], dp[30110][600], x;
int dfs(int s, int l) {
  if (dp[s][l] != -1) return dp[s][l];
  int res = 0, i, v;
  for (i = -1; i <= 1; ++i) {
    v = s + i + l;
    if (v > 30001 || v <= s) continue;
    res = max(res, dfs(v, l + i));
  }
  return dp[s][l] = res + o[s];
}
int main() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k;
  while (n--) {
    cin >> x;
    o[x]++;
  }
  cout << dfs(k, k);
}
506_E. Mr. Kitayuta's Gift

Mr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the same forward and backward. For example, "noon", "testset" and "a" are all palindromes, while "test" and "kitayuta" are not.) You can choose any n lowercase English letters, and insert each of them to any position of s, possibly to the beginning or the end of s. You have to insert exactly n letters even if it is possible to turn s into a palindrome by inserting less than n letters.

Find the number of the palindromes that can be obtained in this way, modulo 10007.

Input

The first line contains a string s (1 ≤ |s| ≤ 200). Each character in s is a lowercase English letter.

The second line contains an integer n (1 ≤ n ≤ 109).

Output

Print the number of the palindromes that can be obtained, modulo 10007.

Examples

Input

revive
1


Output

1


Input

add
2


Output

28

Note

For the first sample, you can obtain the palindrome "reviver" by inserting 'r' to the end of "revive".

For the second sample, the following 28 palindromes can be obtained: "adada", "adbda", ..., "adzda", "dadad" and "ddadd".

Example input:
add
2

revive
1


Example output:
adda

reviver


Tags: combinatorics
dp
matrices
strings
Difficulty rating: 3000

Solution:
s=input()
for i in range(len(s)+1):
	for j in range(97,123):
		q=s[:i]+chr(j)+s[i:]
		if q==q[::-1]:
			print(q)
			exit()
print("NA")
530_G. Levenshtein distance

Levenshtein distance between two strings of letters is calculated as the minimal total cost of a sequence of edit actions that converts one of the strings into the other one. The allowed edit actions are:

  * substitution: the cost of substituting one letter with another is equal to the difference of index numbers of these letters in English alphabet.
  * insertion/deletion: the cost of inserting a letter into a string or deleting a letter from a string is equal to the index number of this letter in English alphabet (see examples).



You are given two strings. Find the Levenshtein distance between them.

Input

The input data consists of two lines, each line contains a string of lowercase Latin letters. Each string is between 1 and 100 letters long, inclusive.

Output

Output a single integer — the Levenshtein distance between the strings.

Examples

Input

arc
bug


Output

8


Input

dome
drone


Output

19

Note

In the first example you should replace a with b (cost 1), r with u (cost 3) and c with g (cost 4).

In the second example you should insert r (cost 18) are replace m with n (cost 1).

Example input:
arc
bug

dome
drone


Example output:
8

19


Tags: *special
Difficulty rating: 2100

Solution:
540_D. Bad Luck Island

The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one individual kills the other one: a rock kills scissors, scissors kill paper, and paper kills a rock. Your task is to determine for each species what is the probability that this species will be the only one to inhabit this island after a long enough period of time.

Input

The single line contains three integers r, s and p (1 ≤ r, s, p ≤ 100) — the original number of individuals in the species of rock, scissors and paper, respectively.

Output

Print three space-separated real numbers: the probabilities, at which the rocks, the scissors and the paper will be the only surviving species, respectively. The answer will be considered correct if the relative or absolute error of each number doesn't exceed 10 - 9.

Examples

Input

2 2 2


Output

0.333333333333 0.333333333333 0.333333333333


Input

2 1 2


Output

0.150000000000 0.300000000000 0.550000000000


Input

1 1 3


Output

0.057142857143 0.657142857143 0.285714285714

Example input:
2 1 2

2 2 2

1 1 3


Example output:
0.15 0.3 0.55

0.333333333333333 0.333333333333333 0.333333333333333

0.0571428571428571 0.657142857142857 0.285714285714286


Tags: dp
probabilities
Difficulty rating: 1900

Solution:
#include <bits/stdc++.h>
using namespace std;
double dp[110][110][110];
int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  for (int i = 1; i <= 100; i++)
    for (int j = 1; j <= 100; j++) {
      dp[i][j][0] = 1;
      for (int k = 1; k <= 100; k++)
        dp[i][j][k] += (i * j * dp[i][j - 1][k] + j * k * dp[i][j][k - 1] +
                        k * i * dp[i - 1][j][k]) /
                       (i * j + j * k + k * i);
    }
  printf("%.10lf %.10lf %.10lf\n", dp[a][b][c], dp[b][c][a], dp[c][a][b]);
  return 0;
}
552_E. Vanya and Brackets

Vanya is doing his maths homework. He has an expression of form <image>, where x1, x2, ..., xn are digits from 1 to 9, and sign <image> represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of brackets in this expression so that to maximize the value of the resulting expression.

Input

The first line contains expression s (1 ≤ |s| ≤ 5001, |s| is odd), its odd positions only contain digits from 1 to 9, and even positions only contain signs  +  and  * . 

The number of signs  *  doesn't exceed 15.

Output

In the first line print the maximum possible value of an expression.

Examples

Input

3+5*7+8*4


Output

303


Input

2+3*5


Output

25


Input

3*4*5


Output

60

Note

Note to the first sample test. 3 + 5 * (7 + 8) * 4 = 303.

Note to the second sample test. (2 + 3) * 5 = 25.

Note to the third sample test. (3 * 4) * 5 = 60 (also many other variants are valid, for instance, (3) * 4 * 5 = 60).

Example input:
3+5*7+8*4

2+3*5

3*4*5


Example output:
303

25

60


Tags: brute force
dp
expression parsing
greedy
implementation
strings
Difficulty rating: 2100

Solution:
a="1*"+input()+"*1"
ans=eval(a)
l=len(a)
for i in range(l):
	if a[i]=='*':
		for j in range(i+1,l):
			if a[j]=='*':
				ans=max(ans,eval(a[:i+1]+'('+a[i+1:j]+')'+a[j:]))
print(ans)
55_E. Very simple problem

You are given a convex polygon. Count, please, the number of triangles that contain a given point in the plane and their vertices are the vertices of the polygon. It is guaranteed, that the point doesn't lie on the sides and the diagonals of the polygon.

Input

The first line contains integer n — the number of vertices of the polygon (3 ≤ n ≤ 100000). The polygon description is following: n lines containing coordinates of the vertices in clockwise order (integer x and y not greater than 109 by absolute value). It is guaranteed that the given polygon is nondegenerate and convex (no three points lie on the same line).

The next line contains integer t (1 ≤ t ≤ 20) — the number of points which you should count the answer for. It is followed by t lines with coordinates of the points (integer x and y not greater than 109 by absolute value).

Output

The output should contain t integer numbers, each on a separate line, where i-th number is the answer for the i-th point.

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Examples

Input

4
5 0
0 0
0 5
5 5
1
1 3


Output

2


Input

3
0 0
0 5
5 0
2
1 1
10 10


Output

1
0


Input

5
7 6
6 3
4 1
1 2
2 4
4
3 3
2 3
5 5
4 2


Output

5
3
3
4

Example input:
4
5 0
0 0
0 5
5 5
1
1 3

3
0 0
0 5
5 0
2
1 1
10 10

5
7 6
6 3
4 1
1 2
2 4
4
3 3
2 3
5 5
4 2


Example output:
2

1
0

5
3
3
4


Tags: geometry
two pointers
Difficulty rating: 2500

Solution:
#include <bits/stdc++.h>
struct Point {
  long long x, y;
} a[100001];
long long cross(Point &a, Point &b, Point &c) {
  return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
}
int main() {
  int n, t, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%I64d%I64d", &a[i].x, &a[i].y);
  a[n] = a[0];
  scanf("%d", &t);
  long long ans, k;
  Point p;
  while (t--) {
    scanf("%I64d%I64d", &p.x, &p.y);
    ans = (long long)n * (n - 1) * (n - 2) / 6;
    j = 1;
    for (i = 0; i < n; ++i) {
      if (cross(p, a[i], a[i + 1]) > 0) {
        ans = 0;
        break;
      }
      while (cross(p, a[i], a[j]) < 0) j = (j + 1) % n;
      k = (n + i - j - 1) % n;
      ans -= k * (k + 1) / 2;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
605_C. Freelancer's Dreams

Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his dreams and registered at a freelance site.

He has suggestions to work on n distinct projects. Mikhail has already evaluated that the participation in the i-th project will increase his experience by ai per day and bring bi dollars per day. As freelance work implies flexible working hours, Mikhail is free to stop working on one project at any time and start working on another project. Doing so, he receives the respective share of experience and money. Mikhail is only trying to become a cool programmer, so he is able to work only on one project at any moment of time.

Find the real value, equal to the minimum number of days Mikhail needs to make his dream come true.

For example, suppose Mikhail is suggested to work on three projects and a1 = 6, b1 = 2, a2 = 1, b2 = 3, a3 = 2, b3 = 6. Also, p = 20 and q = 20. In order to achieve his aims Mikhail has to work for 2.5 days on both first and third projects. Indeed, a1·2.5 + a2·0 + a3·2.5 = 6·2.5 + 1·0 + 2·2.5 = 20 and b1·2.5 + b2·0 + b3·2.5 = 2·2.5 + 3·0 + 6·2.5 = 20.

Input

The first line of the input contains three integers n, p and q (1 ≤ n ≤ 100 000, 1 ≤ p, q ≤ 1 000 000) — the number of projects and the required number of experience and money.

Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 1 000 000) — the daily increase in experience and daily income for working on the i-th project.

Output

Print a real value — the minimum number of days Mikhail needs to get the required amount of experience and money. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6. 

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if <image>.

Examples

Input

3 20 20
6 2
1 3
2 6


Output

5.000000000000000


Input

4 1 1
2 3
3 2
2 3
3 2


Output

0.400000000000000

Note

First sample corresponds to the example in the problem statement.

Example input:
3 20 20
6 2
1 3
2 6

4 1 1
2 3
3 2
2 3
3 2


Example output:
5.0000000
0.4000000

Tags: geometry
Difficulty rating: 2400

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005], p, q;
double l, r = 1, y, m1, m2, d;
double F(double x) {
  y = 1;
  for (int i = 1; i <= n; i++) y = min(y, (1 - a[i] * x) / b[i]);
  return x * p + q * y;
}
int main() {
  cin >> n, cin >> p, cin >> q;
  for (int i = 1; i <= n; i++) cin >> a[i], cin >> b[i], r = min(r, 1.0 / a[i]);
  while (r - l > 1e-15) {
    d = (r - l) / 3, m1 = l + d, m2 = r - d;
    if (F(m1) > F(m2))
      r = m2;
    else
      l = m1;
  }
  printf("%.8lf\n", F(l));
}
612_C. Replace To Make Regular Bracket Sequence

You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {, but you can't replace it by ) or >.

The following definition of a regular bracket sequence is well-known, so you can be familiar with it.

Let's define a regular bracket sequence (RBS). Empty string is RBS. Let s1 and s2 be a RBS then the strings <s1>s2, {s1}s2, [s1]s2, (s1)s2 are also RBS.

For example the string "[[(){}]<>]" is RBS, but the strings "[)()" and "][()()" are not.

Determine the least number of replaces to make the string s RBS.

Input

The only line contains a non empty string s, consisting of only opening and closing brackets of four kinds. The length of s does not exceed 106.

Output

If it's impossible to get RBS from s print Impossible.

Otherwise print the least number of replaces needed to get RBS from s.

Examples

Input

[&lt;}){}


Output

2

Input

{()}[]


Output

0

Input

]]


Output

Impossible

Example input:
{()}[]

[&lt;}){}

]]


Example output:
0

Impossible

Impossible


Tags: data structures
expression parsing
math
Difficulty rating: 1400

Solution:
k, s = 0, []
for q in input():
    i = '[{<(]}>)'.find(q)
    if i > 3:
        if not s:
            s = 1
            break
        if s.pop() != i - 4: k += 1
    else: s += [i]
print('Impossible' if s else k)