#include <bits/stdc++.h>
using namespace std;
int n, m, t;
char a[210][210];
int vis[210][210];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int sx, sy, ex, ey;
struct node
{
int x, y;
};
queue<node> q;
int main()
{
cin >> n >> m >> t;
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= m; j ++ )
{
cin >> a[i][j];
if (a[i][j] == '@') sx = i, sy = j;
if (a[i][j] == '+') ex = i, ey = j;
}
cout << bfs(sx, sy) << endl;
return 0;
}