#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
double eudis(pair<int, int> p1, pair<int, int> p2) {
  int x = abs(p1.first - p2.first);
  x *= x;
  int y = abs(p1.second - p2.second);
  y *= y;
  return sqrt(double(x) + double(y));
}
void solve() {
  int n, m, x;
  char t;
  cin >> n >> m >> x;
  map<char, vector<pair<int, int>>> um;
  unordered_map<char, int> uc;
  set<pair<int, int>> us;
  int cs = 0;
  unordered_map<char, double> shrtup;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> t;
      if (t == 'S') {
        cs++;
        us.insert(make_pair(i + 1, j + 1));
      } else {
        um[t].push_back(make_pair(i + 1, j + 1));
        uc[t] = 10;
      }
    }
  }
  for (auto xod : um) {
    vector<pair<int, int>> vp = xod.second;
    double dis = 10000000;
    for (auto uvx : vp) {
      double tmp;
      for (auto it : us) {
        tmp = eudis(uvx, it);
        dis = min(dis, tmp);
      }
    }
    shrtup[xod.first] = dis;
  }
  int q;
  cin >> q;
  int cnt = 0, fg = 0;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (uc[t] == 10 || uc[t + 32] == 10) {
      if (uc[t + 32] == 10 && cs == 0) {
        fg = 1;
      } else if (int(t) >= 65 && int(t) <= 90) {
        if (shrtup[t + 32] > double(x)) {
          cnt++;
        }
      }
    } else {
      fg = 1;
      break;
    }
    if (fg == 1) {
      break;
    }
  }
  if (fg == 0) {
    cout << cnt;
  } else {
    cout << -1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  for (int t = 1; t <= tc; t++) {
    solve();
  }
}
