#include <iostream>
using namespace std;
int main ()
{
 {
    int bc, bts, bk, bt, bp, bo, chc, chts, chk, cht, chp, cho;
    cin >> bc >> bts >> bk >> bt >> bp >> bo;
    cin >> chc >> chts >> chk >> cht >> chp >> cho;
    if (bc < 1)
    {
        cout << 1;
    }
    if (bc = 1)
    {
        cout << 0;
    }
    if (bc > 1)
    {
        cout << -1;
    }
        if (bts < 1)
    {
        cout << 1;
    }
    if (bts = 1)
    {
        cout << 0;
    }
    if (bts > 1)
    {
        cout << -1;
    }
        if (bk < 2)
    {
        cout << 2-bk;
    }
    if (bk = 2)
    {
        cout << 0;
    }
    if (bk > 2)
    {
        cout << bk - 2 ;
    }
        if (bt < 2)
    {
        cout <<2-bt;
    }
    if (bt = 2)
    {
        cout << 0;
    }
    if (bo > 2)
    {
        cout << bo-2;
    }
            if (bo < 2)
    {
        cout <<2-bo;
    }
    if (bo = 2)
    {
        cout << 0;
    }
    if (bo > 2)
    {
        cout << bo-2;
    }
            if (bp < 8)
    {
        cout <<8-bp << endl;
    }
    if (bp = 8)
    {
        cout << 0<< endl;
    }
    if (bp > 8)
    {
        cout << bp-8 << endl;
    }
        if (chc < 1)
    {
        cout << 1;
    }
    if (chc = 1)
    {
        cout << 0;
    }
    if (chc > 1)
    {
        cout << -1;
    }
        if (chts < 1)
    {
        cout << 1;
    }
    if (chts = 1)
    {
        cout << 0;
    }
    if (chts > 1)
    {
        cout << -1;
    }
        if (chk < 2)
    {
        cout << 2-chk;
    }
    if (chk = 2)
    {
        cout << 0;
    }
    if (chk > 2)
    {
        cout << chk - 2 ;
    }
        if (cht < 2)
    {
        cout <<2-cht;
    }
    if (cht = 2)
    {
        cout << 0;
    }
    if (cho > 2)
    {
        cout << cho-2;
    }
            if (cho < 2)
    {
        cout <<2-cho;
    }
    if (cho = 2)
    {
        cout << 0;
    }
    if (cho > 2)
    {
        cout << cho-2;
    }
            if (chp < 8)
    {
        cout <<8-chp<< endl;
    }
    if (chp = 8)
    {
        cout << 0<< endl;
    }
    if (chp > 8)
    {
        cout << chp-8<< endl;
    }
}
  return 0;
}

