//
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

struct pos{
    int x;
    int y;
};

struct sta{
    int f;
    int l;
    int d;
};

int main(){
    // CFS;
    int h, w, K;
    cin >> h >> w >> K;
    vector<string> f(h);
    rep(i, h) cin >> f[i];
    vector<pos> app;
    rep(i, h){
        rep(j, w){
            if(f[i][j] == 'a'){
                app.push_back({i, j});
                f[i][j] = '.';
            }

        }
    }
    rep(i, h){
        rep(j, w){
            if(f[i][j] == 's' || f[i][j] == 'e'){
                app.push_back({i, j});
                f[i][j] = '.';
            }
        }
    }

    int sz = app.size();
    mti dist(sz, vi(sz, IINF));
    vi vx = {0, 1, 0, -1};
    vi vy = {1, 0, -1, 0};
    rep(i, sz){
        queue<pos> q;
        mti dis(h, vi(w, IINF));
        q.push({app[i].x, app[i].y});
        dis[app[i].x][app[i].y] = 0;
        while(!q.empty()){
            auto now = q.front();
            q.pop();
            rep(t, 4){
                int nx = now.x + vx[t];
                int ny = now.y + vy[t];
                if(nx < 0 || h <= nx || ny < 0 || w <= ny) continue;
                if(f[nx][ny] == '#') continue;
                if(dis[nx][ny] != IINF) continue;
                dis[nx][ny] = dis[now.x][now.y] + 1;
                q.push({nx, ny});
            }
        }
        rep(j, sz){
            dist[i][j] = dis[app[j].x][app[j].y];
        }
    }

//    rep(i, sz){
//        rep(j, sz){
//            cout << dist[i][j] << " ";
//        }
//        cout << endl;
//    }
    int ans = IINF;

    mti d(1 << sz, vi(sz, IINF));
    d[1 << (sz - 2)][sz - 2] = 0;
    rep(i, 1 << sz){
        rep(j, sz){
            if(d[i][j] == IINF) continue;
            rep(k, sz){
                if(dist[j][k] != IINF && (i&(1<<k))==0)
                    d[i | (1 << k)][k] = min(d[i | (1 << k)][k], d[i][j] + dist[j][k]);
            }
        }
        int c = 0;
        rep(k, sz){
            if(i & (1 << k)) c++;
        }
        if(c >= K + 2){
            ans = min(ans, d[i][sz - 1]);
        }
    }
    if(ans == IINF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}
