#include <bits/stdc++.h>
using namespace std;
const int N = 35, M = 35, U = 5e5 + 5;
char a[N][N];
unordered_map<char, vector<pair<int, int>>> ky;
unordered_map<char, bool> ishr;
vector<pair<int, int>> shifts;
int v[100];
unordered_map<char, int> MM;
int n, m, p;
char num;
int k, z;
double sp1, x;
bool ok(char p) { return p >= 'a' && p <= 'z'; }
int main() {
  cin >> n >> m >> x;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] != 'S') {
        ky[a[i][j]].push_back(make_pair(i, j));
        ishr[a[i][j]] = true;
      } else if (a[i][j] == 'S') {
        shifts.push_back(make_pair(i, j));
      }
    }
  }
  sort(shifts.begin(), shifts.end());
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    bool ky1 = false;
    cin >> num;
    bool h = ishr[tolower(num)];
    bool y = ok(num);
    if (ok(num) == false) {
      v[num - 'A']++;
    }
    if (y == true && h == false) {
      cout << -1;
      return 0;
    } else if (y == false && (h == false || shifts.size() == 0)) {
      cout << -1;
      return 0;
    } else if (ok(num) == false && shifts.size() > 0 &&
               ishr[tolower(num)] == true && MM[num] == 0) {
      num = tolower(num);
      for (int i = 0; i < ky[num].size(); i++) {
        for (int j = 0; j < shifts.size(); j++) {
          sp1 = sqrt(pow(ky[num][i].first - shifts[j].first, 2) +
                     pow(ky[num][i].second - shifts[j].second, 2));
          if (sp1 <= x) {
            ky1 = true;
            break;
          }
        }
        if (ky1 == true) {
          break;
        }
      }
      if (ky1 == false) {
        MM[toupper(num)] = true;
      }
    }
  }
  for (int i = 0; i < 100; i++) {
    if (MM[(char)(i + 65)] == 1) {
      p += v[i];
    }
  }
  cout << p << "\n";
  return 0;
}
