#include <bits/stdc++.h>
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;
const int X[]={0,1,0,-1},Y[]={1,0,-1,0};

int H,W,K,eh,ew,apple,d[30][30],bfs[1001][1001],dp[1<<20][30];
char A[1000][1000];
vector<int>x(1),y(1);

int bitdp(int app,int last){
    if(dp[app][last])return dp[app][last];
    int num=0;
    rep(i,apple)if((app>>i)&1)num++;
    if(num==K)return dp[app][last]=d[last][x.size()-1];
    dp[app][last]=1e7;
    rep(i,apple)if(!((app>>i)&1)){
        dp[app][last]=min(dp[app][last],bitdp(app+(1<<i),i+1)+d[last][i+1]);
    }
    return dp[app][last];
}

int main(){
    cin>>H>>W>>K;
    rep(i,H)rep(j,W){
        cin>>A[i][j];
        if(A[i][j]=='e')eh=i,ew=j;
        if(A[i][j]=='s')x[0]=i,y[0]=j;
        if(A[i][j]=='a'){
            x.push_back(i);
            y.push_back(j);
            apple++;
        }
    }
    x.push_back(eh);
    y.push_back(ew);

    queue<pair<int,int> > que;
    rep(i,x.size()){
        fill(bfs[0],bfs[1001],1e7);
        que.push({x[i],y[i]});
        bfs[x[i]][y[i]]=0;
        while(!que.empty()){
            int nx=que.front().first,ny=que.front().second;
            que.pop();
            rep(j,4){
                int NX=nx+X[j],NY=ny+Y[j];
                if(NX<0||H<=NX||NY<0||W<=NY||A[NX][NY]=='#'||bfs[NX][NY]!=1e7)continue;
                bfs[NX][NY]=bfs[nx][ny]+1;
                que.push({NX,NY});
            }
        }
        rep(j,x.size())d[i][j]=bfs[x[j]][y[j]];
    }

    cout<<(bitdp(0,0)>=1e7?-1:dp[0][0])<<endl;
}
