#include #include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for(long long int i=(a);i<=(b);++i) #define NFOR(i,a,b) for(long long int i=(a);i>=(b);--i) #define pb push_back #define ll long long using namespace std; ll a[3][3]; int main() { ll x; FOR(i,0,2) { FOR(j,0,2) cin>>a[i][j]; } ll cc; ll min=9999999999; ll a1[]={4,9,2,3,5,7,8,1,6,2,7,6,9,5,1,4,3,8,6,1,8,7,5,3,2,9,4,8,3,4,1,5,9,6,7,2,2,9,4,7,5,3,6,1,8,4,3,8,9,5,1,2,7,6,6,7,2,1,5,9,8,3,4,8,1,6,3,5,7,4,9,2}; ll c=0,v=0; FOR(i,1,8) { c=0; FOR(j,0,2) { FOR(k,0,2) { c+=abs(a[j][k]-a1[v++]); } } if(c