#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=5e7;//減ってる
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>int LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>int UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);
	int bi,i,j,H,W,K,ans=mod;cin>>H>>W>>K;
	vector<string>mat(H+2);
	mat[0]=string(W+2,'#');
	mat[H+1]=string(W+2,'#');
	int y[22]={},x[22]={};
	int ak=0;
	for(i=1;i<=H;i++){
		cin>>mat[i];
		mat[i].pub('#');
		mat[i].insert(mat[i].begin(),'#');
		for(j=1;j<=W;j++){
			if(mat[i][j]=='a'){y[ak]=i;x[ak]=j;ak++;}
			if(mat[i][j]=='s'){y[20]=i;x[20]=j;}
			if(mat[i][j]=='e'){y[21]=i;x[21]=j;}
		}
	}
	int kyo[22][22]={};
	for(i=0;i<22;i++){
		
		if(ak<=i&&i<20){continue;}
		//ここからの距離を測る
		vector<vector<int>>dist(H+2,vector<int>(W+2,mod));
		dist[y[i]][x[i]]=0;
		queue<tuple<int,int,int>>que;
		que.push(mt(0,y[i],x[i]));
		while(que.size()){
			int z,ny,nx;tie(z,ny,nx)=que.front();
			que.pop();
			
			if(mat[ny][nx-1]!='#'&&dist[ny][nx-1]==mod){
				dist[ny][nx-1]=z+1;
				que.push(mt(z+1,ny,nx-1));
			}
			if(mat[ny][nx+1]!='#'&&dist[ny][nx+1]==mod){
				dist[ny][nx+1]=z+1;
				que.push(mt(z+1,ny,nx+1));
			}
			if(mat[ny-1][nx]!='#'&&dist[ny-1][nx]==mod){
				dist[ny-1][nx]=z+1;
				que.push(mt(z+1,ny-1,nx));
			}
			if(mat[ny+1][nx]!='#'&&dist[ny+1][nx]==mod){
				dist[ny+1][nx]=z+1;
				que.push(mt(z+1,ny+1,nx));
			}
		}
		for(j=0;j<22;j++){
			if(ak<=j&&j<20){continue;}
			kyo[i][j]=dist[y[j]][x[j]];
		}
	}
	//cerr<<"de"<<endl;
	static int dp[1<<20][20];
	for(bi=0;bi<(1<<ak);bi++){
		for(i=0;i<ak;i++){dp[bi][i]=mod;}
	}
	for(i=0;i<ak;i++){dp[1<<i][i]=kyo[20][i];}
	for(bi=0;bi<(1<<ak);bi++){
		int siz=0;
		for(i=0;i<ak;i++){if(bi&(1<<i)){siz++;}}
		if(siz<K){
			for(i=0;i<ak;i++){
				if(dp[bi][i]>=mod){continue;}
				for(j=0;j<ak;j++){
					if(bi&(1<<j)){continue;}
					mineq(dp[bi+(1<<j)][j],dp[bi][i]+kyo[i][j]);
				}
				
			}
		}else{
			for(i=0;i<ak;i++){mineq(ans,dp[bi][i]+kyo[i][21]);}
		}
	}
	if(ans>=mod){ans=-1;}
	cout<<ans<<endl;
	return 0;
}

