#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long double x, y, z;
} point;
char c[40][40];
map<char, int> mp;
vector<pair<int, int> > v;
map<char, bool> mb;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (char i = 'a'; i <= 'z'; i++) {
    mp[i] = 2000;
  }
  int n, m, x, q;
  cin >> n >> m >> x;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      mb[c[i][j]] = true;
      if (c[i][j] == 'S') v.push_back({i, j});
    }
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j <= m; j++) {
      if (c[i][j] != 'S') {
        for (int k = 0; k < v.size(); k++) {
          mp[c[i][j]] =
              min(mp[c[i][j]], ((i - v[k].first) * (i - v[k].first) +
                                (j - v[k].second) * (j - v[k].second)));
        }
      }
    }
  cin >> q;
  int res = 0;
  bool b = false;
  while (q--) {
    char ch;
    cin >> ch;
    if (ch >= 'A' && ch <= 'Z' && mp[ch + 32] > x * x) res++;
    if (ch >= 'A' && ch <= 'Z' && (mb[ch + 32] == false || v.size() == 0)) {
      b = true;
      continue;
    }
    if (ch >= 'a' && ch <= 'z' && mb[ch] == false) b = true;
  }
  if (b)
    cout << -1;
  else
    cout << res;
  cout << "\n";
  return 0;
}
