#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1010
#define X 22
ll h,w,kkk;
char c[N][N];
int di[N][N];
int dist[50][50];
int dp[X][(1<<X)];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>h>>w>>kkk;
    vector<P> v;
    ll sx,sy,gx,gy;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
	cin>>c[i][j];
	if(c[i][j]=='s')sx=i,sy=j;
	if(c[i][j]=='e')gx=i,gy=j;
    }
    v.push_back(make_pair(sx,sy));
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
	if('a'==c[i][j])v.push_back(make_pair(i,j));
    }
    v.push_back(make_pair(gx,gy));
    for(int t=0;t<v.size();t++){
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)di[i][j]=1e9;
	di[v[t].first][v[t].second]=0;
	queue<P> Q;
	Q.push(v[t]);
	while(!Q.empty()){
	    ll x=Q.front().first,y=Q.front().second;
	    Q.pop();
	    ll dx[]={0,1,0,-1},dy[]={1,0,-1,0};
	    for(int r=0;r<4;r++){
		ll xx=x+dx[r],yy=y+dy[r];
		if(not(0<=xx&&xx<h&&0<=yy&&yy<w))continue;
		if(c[xx][yy]=='#')continue;
		if(di[xx][yy]==1e9){
		    di[xx][yy]=di[x][y]+1;
		    Q.push(make_pair(xx,yy));
		}
	    }
	}
	for(int s=0;s<v.size();s++){
	    dist[t][s]=di[v[s].first][v[s].second];
	}
    }
    int n=v.size()-1; //cout<<n<<endl;
    /*for(int i=0;i<n;i++){
	for(int j=0;j<n;j++)cout<<dist[i][j]<<" ";
	cout<<endl;
    }*/
    for(int i=0;i<n;i++)for(int j=0;j<(1<<n);j++){
	dp[i][j]=1e9;
    }
    dp[0][1]=0;
    for(int j=0;j<(1<<n);j++)for(int i=0;i<n;i++){
	for(int k=0;k<n;k++){
	    if((j&(1<<k)))continue;
	    chmin(dp[k][j+(1<<k)],dp[i][j]+dist[i][k]);
	}
    }
    int ans=1e9;
    for(int j=0;j<(1<<n);j++){
	ll cnt=0;
	for(int k=0;k<n;k++){
	    if(j&(1<<k))cnt++;
	}
	if(cnt-1>=kkk){
	    for(int i=0;i<n;i++){
		chmin(ans,dp[i][j]+dist[i][n]);
	    }
	}
    }
    if(ans>=1e9)ans=-1;
    cout<<ans<<endl;
}



