#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int dist[1010][1010];
int d[]={1,0,-1,0,1};
int a[22][22];
ll dp[1<<20][20];
int main(){
	int h,w,k;
	cin>>h>>w>>k;
	string s[h];
	rep(i,h)cin>>s[i];
	map<pair<int,int>,int> mp;
	int ap=0;
	rep(i,h)rep(j,w){
		if(s[i][j]=='a')mp[{i,j}]=ap++;
	}
	rep(i,h)rep(j,w){
		if(s[i][j]=='s')mp[{i,j}]=ap++;
	}
	rep(i,h)rep(j,w){
		if(s[i][j]=='e')mp[{i,j}]=ap++;
	}
	for(auto e:mp){
		int sx=e.first.first, sy=e.first.second;
		rep(i,h)rep(j,w)dist[i][j]=inf;
		dist[sx][sy]=0;
		queue<pair<int,int>> q;
		q.push(e.first);
		while(q.size()){
			auto p=q.front();q.pop();
			int cx=p.first, cy=p.second;
			rep(i,4){
				int nx=cx+d[i], ny=cy+d[i+1];
				if(nx<0||nx>=h||ny<0||ny>=w)continue;
				if(dist[nx][ny]!=inf)continue;
				if(s[nx][ny]=='#')continue;
				dist[nx][ny]=dist[cx][cy]+1;
				q.emplace(nx,ny);
			}
		}
		for(auto f:mp){
			a[e.second][f.second]=dist[f.first.first][f.first.second];
		}
	}
	int n=ap-2;
	rep(i,1<<n)rep(j,n)dp[i][j]=longinf;
	rep(i,n)dp[1<<i][i]=a[n][i];
	rep(i,1<<n){
		rep(j,n){
			if(((1<<j)&i)==0)continue;
			int pre = i^(1<<j);
			rep(k,n){
				if(((1<<k)&pre)==0)continue;
				dp[i][j]=min(dp[i][j],dp[pre][k]+a[k][j]);
			}
		}
	}
	ll ans = longinf;
	rep(i,1<<n){
		if(__builtin_popcount(i)<k)continue;
		rep(j,n)ans = min(ans,dp[i][j]+a[j][n+1]);
	}
	if(ans>=inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}
