#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > S;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, x;
  char ch[43][43];
  bool mas[700];
  cin >> n >> m >> x;
  bool flag = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ch[i][j];
      if (ch[i][j] == 'S') {
        ch[i][j] = 0;
        flag = true;
        S.push_back(make_pair(i, j));
      }
    }
  }
  x *= x;
  memset(mas, 0, sizeof(mas));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ch[i][j] != 0) {
        mas[ch[i][j] + 256] = true;
        for (int k = 0; k < S.size(); k++) {
          if ((i - S[k].first) * (i - S[k].first) +
                  (j - S[k].second) * (j - S[k].second) <=
              x) {
            mas[ch[i][j] - 32 + 256] = true;
            break;
          }
        }
      }
    }
  }
  int q;
  cin >> q;
  char c;
  int ans = 0;
  for (int i = 0; i < q; i++) {
    cin >> c;
    if (c >= 'A' && c <= 'Z') {
      if (!flag) {
        cout << -1;
        return 0;
      }
      if (mas[c + 256]) continue;
      if (!mas[c + 256] && mas[c + 256 + 32]) {
        ans++;
      } else {
        cout << -1;
        return 0;
      }
    } else {
      if (!mas[c + 256]) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans;
  return 0;
}
