// Aditya Kakkar

// February 26, 2013

// Contest #3

// JR 5

// Potter

 

#include <iostream>

 

using namespace std;

 

void input(int x, int y, int N) {

cout<<"Enter Row ";

cin>>x;

cout<< "Enter Column ";

cin>>y;

cout<< "Enter Number of Moves ";

cin>>N;

 

int counter=1;

for(int i=1; i<=N;i++) {

if (1<=(x+i) && (x+i)<=5){

counter++;

}

if (1<=(y+i) && (y+i)<=5){

counter++;

}

if (1<=(x-i) && (x-i)<=5){

counter++;

}

if (1<=(y-i) && (y-i)<=5){

counter++;

}

if (1<=(x+i) && (x+i)<=5 && 1<=(y+i) && (y+i)<=5){

counter++;

}

if (1<=(x+i) && (x+i)<=5 && 1<=(y-i) && (y-i)<=5){

counter++;

}

if (1<=(x-i) && (x-i)<=5 && 1<=(y+i) && (y+i)<=5){

counter++;

}

if (1<=(x-i) && (x-i)<=5 && 1<=(y-i) && (y-i)<=5){

counter++;

}

}

cout<<endl<<(25-counter)<<endl<<endl;

}

 

int main() {

int x;

int y;

int N;

for(int i=0; i<5; i++) {

input(x,y,N);

}

return 0;

}