#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 1005

struct LOC{

	int row,col;
};

struct Info{
	Info(int arg_row,int arg_col,char arg_ch){
		loc.row = arg_row;
		loc.col = arg_col;
		ch = arg_ch;
	}

	LOC loc;
	char ch;
};

int H,W;
int info_index[128],min_dist[128][128];
char table[55][55],buf[SIZE];
vector<Info> V;


void func(){

	V.clear();

	for(int row = 0; row < H; row++){

		scanf("%s",table[row]);
		for(int col = 0; col < W; col++){

			if(table[row][col] == '_')continue;

			info_index[table[row][col]] = V.size(); //文字からインデックスを調べる表
			V.push_back(Info(row,col,table[row][col]));
		}
	}

	scanf("%s",buf);

	for(int i = 0; i < V.size()-1; i++){
		for(int k = i; k < V.size(); k++){

			min_dist[V[i].ch][V[k].ch] = abs(V[i].loc.row-V[k].loc.row)+abs(V[i].loc.col-V[k].loc.col);
			min_dist[V[k].ch][V[i].ch] = min_dist[V[i].ch][V[k].ch];
		}
	}

	int ans = V[info_index[buf[0]]].loc.row+V[info_index[buf[0]]].loc.col+1;

	char pre = buf[0];

	for(int i = 1; buf[i] != '\0'; i++){

		ans += min_dist[pre][buf[i]]+1;
		pre = buf[i];
	}

	printf("%d\n",ans);
}

int main(){

	while(true){

		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;

		func();
	}

	return 0;
}

