#include<iostream>
#include<vector>
using namespace std;

int main(){
    int h, w;
    while(cin >> h >> w, h){
        vector<string> r(h);
        for(int i = 0 ; i < h ; ++i){
            cin >> r[i];
        }

        string s;
        cin >> s;

        int y = 0, x = 0;
        int ans = 0;
        for(auto c : s){
            for(int i = 0 ; i < h ; ++i){
                for(int j = 0 ; j < w ; ++j){
                    if(r[i][j] == c){
                        ans += abs(i - y) + abs(j - x) + 1;
                        y = i;
                        x = j;
                    }
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}
