#include <bits/stdc++.h>
using namespace std;
double Distance(int x1, int x2, int y1, int y2) {
  return (double)(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, m, d;
  cin >> n >> m >> d;
  vector<pair<char, pair<int, int>>> data;
  vector<pair<int, int>> shifts;
  map<char, double> minDis;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char x;
      cin >> x;
      if (x == 'S')
        shifts.push_back({i, j});
      else
        data.push_back({x, {i, j}});
    }
  }
  for (int i = 0; i < data.size(); i++) {
    double mn = 1e9;
    for (int j = 0; j < shifts.size(); j++) {
      double dis = sqrt(Distance(shifts[j].first, data[i].second.first,
                                 shifts[j].second, data[i].second.second));
      mn = min(mn, dis);
    }
    if (minDis.find(data[i].first) != minDis.end()) {
      minDis[data[i].first] = min(mn, minDis[data[i].first]);
    } else
      minDis[data[i].first] = mn;
  }
  int z;
  cin >> z;
  int ans = 0;
  for (int i = 0; i < z; i++) {
    char x;
    cin >> x;
    bool upper = false;
    if (isupper(x)) {
      upper = true;
    }
    if (upper) {
      if (shifts.size() == 0) {
        cout << -1;
        return 0;
      }
    }
    x = tolower(x);
    if (minDis.find(x) == minDis.end()) {
      cout << -1;
      return 0;
    }
    if (upper)
      if (minDis[x] > d) ans++;
  }
  cout << ans;
  return 0;
}
