//* Problem  : 1060 - Flip Game
//* Contest  : acm.timus.ru
//* Type     : Solution
//* Date     : 2007.10.01
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0


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

int res;
char a[6][6], b[6][6];
char c[17];

void solve();
void result();


int main()
{
	scanf("%s", &a[1][1]); scanf("%s", &a[2][1]); scanf("%s", &a[3][1]); scanf("%s", &a[4][1]);
	solve();
	result();
	return 0;
}

void turn(int k)
{
	int row = (k-1)/4 + 1;
	int col = (k-1)%4 + 1;
	b[row-1][col] = 1 - b[row-1][col];
	b[row][col-1] = 1 - b[row][col-1];
	b[row][col] = 1 - b[row][col];
	b[row+1][col] = 1 - b[row+1][col];
	b[row][col+1] = 1 - b[row][col+1];
}


void incr()
{
	int pos = 16;
	while (pos > 1 && c[pos]) {c[pos] = 0; turn(pos); pos--;}
	c[pos] = 1; turn(pos);
}


void check()
{
	int i, j;
	int t = 0;
	for (i = 1; i <= 4; i++)
		for (j = 1; j <= 4; j++)
			if (b[i][j] != b[1][1]) return;
	for (i = 1; i <= 16; i++)
		if (c[i]) t++;
	if (t < res) res = t;
}

void solve()
{
	memset(c, 0, sizeof(c));
	memcpy(b, a, sizeof(b));
	int i, j;
	for (i = 1; i <= 4; i++)
		for (j = 1; j <= 4; j++)
			if (b[i][j] == 'w') b[i][j] = 0; 
				else b[i][j] = 1;
	res = 1000000000;
	check();
	for (i = 0; i < (2<<15); i++)
	{
		incr();
		check();
	}
}

void result()
{
	if (res == 1000000000) printf("Impossible\n");
		else printf("%d\n", res);
}
