#include <iostream>
using namespace std;
int main(void){
  for(;;){
    int h, w;
    cin >> h >> w;
    if(h == 0 && w == 0){ return 0; }
    string r[h];
    for(int i=0;i<h;i++){
      cin >> r[i];
    }
    string s;
    cin >> s;

    // Constructing a mapping from character to coordiante:
    // c |-> (x[c], y[c]) 
    int x[128]; int y[128];
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	x[r[i][j]] = i;
	y[r[i][j]] = j;
      }
    }

    int tempx = 0; int tempy = 0;
    int d=0;
    for(int i=0;i<s.length();i++){
      d += abs(x[s[i]] - tempx) + abs(y[s[i]] - tempy) + 1;
      tempx = x[s[i]]; tempy = y[s[i]];
    }

    cout << d << endl;
  }
}

