#include <bits/stdc++.h>
using namespace std;
int mindist[26];
int sumdist[26];
int main() {
  for (int i = 0; i < 26; i++) {
    mindist[i] = 1000000;
  }
  pair<int, int> s;
  int dsgfrdgr;
  vector<pair<int, int> > shifts;
  set<char> alphabet;
  int dist;
  int n, m, x;
  cin >> n >> m >> x;
  char keyboard[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> keyboard[i][j];
      if (keyboard[i][j] == 'S') {
        s = make_pair(i, j);
        shifts.push_back(s);
      } else {
        alphabet.insert(keyboard[i][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (keyboard[i][j] != 'S') {
        for (int k = 0; k < shifts.size(); k++) {
          dist = (i - shifts[k].first) * (i - shifts[k].first) +
                 (j - shifts[k].second) * (j - shifts[k].second);
          if (dist < mindist[(int)keyboard[i][j] - 97]) {
            mindist[(int)keyboard[i][j] - 97] = dist;
          }
        }
      }
    }
  }
  for (int i = 0; i < 26; i++) {
    if (mindist[i] > x * x) {
      sumdist[i] = 1;
    } else {
      sumdist[i] = 0;
    }
  }
  int ans = 0;
  int l;
  cin >> l;
  char test;
  int flag = 0;
  int coinc;
  for (int i = 0; i < l; i++) {
    cin >> test;
    if (test >= 'a' && test <= 'z') {
      coinc = 0;
      for (set<char>::iterator iter = alphabet.begin(); iter != alphabet.end();
           iter++) {
        if (*iter == test) {
          coinc++;
        }
      }
      if (coinc == 0) {
        flag = 1;
      }
    } else {
      if (shifts.size() == 0) {
        flag = 1;
      }
      coinc = 0;
      for (set<char>::iterator iter = alphabet.begin(); iter != alphabet.end();
           iter++) {
        if (*iter == test + 32) {
          coinc++;
        }
      }
      if (coinc == 0) {
        flag = 1;
      }
      ans += sumdist[(int)test - 65];
    }
  }
  if (flag == 1) {
    cout << -1;
  } else {
    cout << ans;
  }
}
