#include <bits/stdc++.h>
using namespace std;
char s[31][31], a[500001];
bool has[26], ok[26];
vector<pair<int, int> > v, t;
int sqr(int n) { return n * n; }
int cal(pair<int, int> x, pair<int, int> y) {
  return sqr(x.first - y.first) + sqr(x.second - y.second);
}
int main() {
  int r, c, x, i, k, Min, n, ret = 0;
  scanf("%d %d %d", &r, &c, &x);
  for (i = 0; i < r; i++) {
    scanf("%s", s[i]);
    for (k = 0; k < c; k++)
      if (s[i][k] == 'S') {
        v.push_back(make_pair(i, k));
      } else {
        has[s[i][k] - 'a'] = true;
        t.push_back(make_pair(i, k));
      }
  }
  x *= x;
  for (i = 0; i < t.size(); i++) {
    Min = INT_MAX;
    for (k = 0; k < v.size(); k++) {
      Min = min(Min, cal(t[i], v[k]));
    }
    ok[s[t[i].first][t[i].second] - 'a'] |= Min <= x;
  }
  scanf("%d %s", &n, a);
  for (i = 0; i < n; i++) {
    if ('a' <= a[i] && a[i] <= 'z') {
      if (!has[a[i] - 'a']) {
        printf("-1");
        return 0;
      }
    } else {
      if (!has[a[i] - 'A'] || !v.size()) {
        printf("-1");
        return 0;
      }
      ret += !ok[a[i] - 'A'];
    }
  }
  printf("%d", ret);
  return 0;
}
