
import java.util.Scanner;
public class Main {
static String[] map;
static step[] queue;
static int[][] move = {{0,1},{0,-1},{1,0},{-1,0}};
static int[][][] visit;
static int time;
static class step{
int x,y,pre;
int k;
public step(int x,int y,int pre,int k) {
this.x=x;
this.y=y;
this.pre=pre;
this.k=k;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getPre() {
return pre;
}
public int getK() {
return k;
}
}
public static void main(String[] args) {
Scanner reader=new Scanner(System.in);
time=0;
int N1=reader.nextInt();
int N2=reader.nextInt();
int k=reader.nextInt();
int mingrenX=0,mingrenY=0,zuozuX=0,zuozuY=0;
queue=new step[210*210];
visit=new int[N1][N2][15];
map=new String[N1];
for(int i=0;i<N1;i++) {
map[i]=reader.next();
for(int j=0;j<N2;j++) {
if(map[i].charAt(j)=='@') {
mingrenX=i;
mingrenY=j;
}
if(map[i].charAt(j)=='+') {
zuozuX=i;
zuozuY=j;
}
}
}
int head=0,tail=0;
queue[head]=new step(mingrenX, mingrenY,-1,k);
visit[mingrenX][mingrenY][k]=1;
tail++;
boolean flag=false;
while(head<tail) {
flag=false;
for(int i=0;i<4;i++) {
int nx=queue[head].getX()+move[i][0];
int ny=queue[head].getY()+move[i][1];
if(nx >= 0 && nx < N1 && ny >= 0 && ny < N2 ) {
if(map[nx].charAt(ny)!='#'&& visit[nx][ny][queue[head].getK()] == 0) {
visit[nx][ny][queue[head].getK()]=1;
queue[tail]=new step(nx, ny, head,queue[head].getK());
tail++;
}
if(map[nx].charAt(ny)=='#'&&queue[head].getK()>=1&&visit[nx][ny][queue[head].getK()-1]==0) {
visit[nx][ny][queue[head].getK()-1]=1;
queue[tail]=new step(nx, ny, head,queue[head].getK()-1);
tail++;
}
}
if(nx==zuozuX&&ny==zuozuY) {
flag=true;
break;
}
}
if(flag) {
print(queue[tail-1]);
System.out.println(time);
break;
}
head++;
}
if(!flag)System.out.println(-1);
}
static void print(step s) {
if(s.pre==-1) {
return;
}
else {
print(queue[s.getPre()]);
time++;
}
}
}