#include<bits/stdc++.h>

using namespace std;

int m, n;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
char c[205][205];
int vis[205][205];
int ans = 100000;
int dis[205][205];

void dfs(int x, int y, int cnt) {
    if (cnt >= ans || cnt >= dis[x][y])//剪枝
        return;
    if (c[x][y] == 'a') {
        //路径可能多条,选择最优
        ans = min(ans, cnt);
        return;
    }
    dis[x][y] = min(dis[x][y], cnt);
    for (int i = 0; i < 4; i++) {
        int xx = x + dx[i];
        int yy = y + dy[i];
        if (!vis[xx][yy] && c[xx][yy] != '#' && xx >= 1 && yy >= 1 && xx <= n && yy <= m) {
            //道路的话直接走
            if (c[xx][yy] == '@' || c[xx][yy] == 'r' || c[xx][yy] == 'a') {
                vis[xx][yy] = 1;
                dfs(xx, yy, cnt + 1);
                vis[xx][yy] = 0;
            }
                //不是道路的话,可以杀死守卫
            else {
                vis[xx][yy] = 1;
                dfs(xx, yy, cnt + 2);
                vis[xx][yy] = 0;
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    cin >> n >> m;
    memset(dis, 0x3f, sizeof dis);
    int x, y;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; ++j) {
            cin >> c[i][j];
            if (c[i][j] == 'r') {
                x = i, y = j;
            }
        }
    }
    vis[x][y] = 1;
    dfs(x, y, 0);
    if (ans == 100000)
        cout << "Impossible";
    else
        cout << ans;
    return 0;
}