#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef int ll;
typedef pair<int,int>P;

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f;
const int MOD=1000000007;

char s[2000][2000];
int id[2000][2000];
int dist[1100][1100];

int d[30][30];
ll dp[1<<22][22];

int dx[]{1,-1,0,0},dy[]{0,0,1,-1};

int main(){
	int h,w,K;cin>>h>>w>>K;
	vector<P>v;
	int sid=0;
	int eid=0;
	rep(i,h){
		scanf("%s",s[i]);
		rep(j,w){
			if(s[i][j]=='a'||s[i][j]=='s'||s[i][j]=='e'){
				id[i][j]=v.size();
				if(s[i][j]=='s')sid=v.size();
				if(s[i][j]=='e')eid=v.size();
				v.push_back(P(i,j));
			}
		}
	}
	memset(d,0x3f,sizeof(d));
	rep(i,v.size()){
		queue<P>que;
		memset(dist,0x3f,sizeof(dist));
		dist[v[i].first][v[i].second]=0;
		que.push(P(v[i].first,v[i].second));
		while(!que.empty()){
			P p=que.front();que.pop();
			rep(k,4){
				int nx=p.first+dx[k],ny=p.second+dy[k];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]!='#'&&dist[nx][ny]>dist[p.first][p.second]+1){
					dist[nx][ny]=dist[p.first][p.second]+1;
					que.push(P(nx,ny));
				}
			}
		}
		rep(j,v.size()){
			d[i][j]=dist[v[j].first][v[j].second];
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[1<<sid][sid]=0;
	rep(i,1<<v.size())rep(j,v.size()){
		if(dp[i][j]==INFL)continue;
		rep(k,v.size()){
			if(i>>k&1)continue;
			if(d[j][k]==INF)continue;
			dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+d[j][k]);
		}
	}
	ll Min=INFL;
	rep(i,1<<v.size()){
		if(__builtin_popcount(i)>=K+2)Min=min(Min,dp[i][eid]);
	}
	if(Min==INFL)puts("-1");
	else cout<<Min<<endl;
}
