#include <bits/stdc++.h>
using namespace std;

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int pop_count(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

void chmin(int64_t& a, int64_t b){
    a = min(a, b);
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    string S[1000];
    vector<pair<int, int>> pos;
    pair<int, int> ps, pg;
    for(int i=0; i<H; i++){
        cin >> S[i];
        for(int j=0; j<W; j++){
            if(S[i][j] == 's') ps = {i, j};
            if(S[i][j] == 'e') pg = {i, j};
            if(S[i][j] == 'a') pos.emplace_back(i, j);
        }
    }
    int KK = pos.size();

    const int64_t INF = 1e15;
    int64_t dist[20][20], grid_dist[1000][1000], toS[20], toG[20];
    const int dx[] = {-1, 1, 0, 0};
    const int dy[] = {0, 0, -1, 1};
    auto inside = [&](int i, int j){ return 0<=i && i<H && 0<=j && j<W && S[i][j] != '#'; };

    for(int k=0; k<KK; k++){
        for(int i=0; i<H; i++) for(int j=0; j<W; j++) grid_dist[i][j] = INF;
        queue<pair<int, int>> que;
        grid_dist[pos[k].first][pos[k].second] = 0;
        que.push(pos[k]);
        while(que.size()){
            auto p = que.front(); que.pop();
            int i = p.first, j = p.second;
            for(int t=0; t<4; t++){
                int x = i + dx[t], y = j + dy[t];
                if(inside(x, y) && grid_dist[x][y] == INF){
                    grid_dist[x][y] = grid_dist[i][j] + 1;
                    que.emplace(x, y);
                }
            }
        }
        toS[k] = grid_dist[ps.first][ps.second];
        toG[k] = grid_dist[pg.first][pg.second];
        for(int l=0; l<KK; l++) dist[k][l] = grid_dist[pos[l].first][pos[l].second];
    }

    static int64_t dp[1<<20][20];
    for(int i=0; i<(1<<KK); i++) for(int k=0; k<KK; k++) dp[i][k] = INF;
    for(int k=0; k<KK; k++) dp[1<<k][k] = toS[k];
    for(int i=0; i<(1<<KK); i++) for(int k=0; k<KK; k++) for(int t=0; t<KK; t++) if(!nth_bit(i, t)){
        chmin(dp[i+(1<<t)][t], dp[i][k] + dist[k][t]);
    }

    int64_t ans = INF;
    for(int i=0; i<(1<<KK); i++) if(pop_count(i) >= K) for(int k=0; k<KK; k++) chmin(ans, dp[i][k] + toG[k]);
    if(ans >= INF) ans = -1;
    cout << ans << endl;
    return 0;
}

