#include <bits/stdc++.h>
using namespace std;
int n, m, d, q;
int malo[30];
int velo[30];
vector<pair<int, int> > shiftevi;
char mat[35][35];
char slovo;
double udaljenost(int x1, int y1, int x2, int y2) {
  double x = (x1 - x2) * (x1 - x2);
  double y = (y1 - y2) * (y1 - y2);
  return sqrt(x + y);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> d;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
      if (mat[i][j] == 'S')
        shiftevi.push_back({i, j});
      else
        malo[mat[i][j] - 'a']++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x = mat[i][j] - 'a';
      if (velo[x]) continue;
      for (auto ns : shiftevi) {
        if (udaljenost(ns.first, ns.second, i, j) <= d) {
          velo[x]++;
          break;
        }
      }
    }
  }
  bool moguce = true;
  int koliko = 0;
  cin >> q;
  while (q--) {
    cin >> slovo;
    if (slovo < 'a') {
      int x = slovo - 'A';
      if (!malo[x])
        moguce = false;
      else if (shiftevi.empty())
        moguce = false;
      else if (!velo[x])
        koliko++;
    } else {
      int x = slovo - 'a';
      if (!malo[x]) moguce = false;
    }
  }
  if (!moguce)
    cout << -1 << '\n';
  else
    cout << koliko << '\n';
  return 0;
}
