#include <bits/stdc++.h>
using namespace std;
double min(double a, double b) { return (a > b ? b : a); }
void solve() {
  int n, m, p;
  cin >> n >> m >> p;
  vector<string> s(n);
  vector<pair<int, int>> shift;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S') shift.push_back({i, j});
    }
  }
  map<char, double> map1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] != 'S') {
        double min_dist = 10e9;
        for (int l = 0; l < shift.size(); l++) {
          min_dist =
              min(min_dist, sqrt((j - shift[l].second) * (j - shift[l].second) +
                                 (i - shift[l].first) * (i - shift[l].first)));
        }
        if (map1.find(s[i][j]) == map1.end()) {
          map1[s[i][j]] = min_dist;
        } else {
          if (min_dist < map1[s[i][j]]) {
            map1[s[i][j]] = min_dist;
          }
        }
      }
    }
  }
  int z;
  cin >> z;
  string word;
  cin >> word;
  int hand = 0;
  for (int i = 0; i < word.size(); i++) {
    if (word[i] >= 'a') {
      bool found = 0;
      if (map1.find(word[i]) != map1.end()) {
        found = 1;
      }
      if (!found) {
        cout << -1 << "\n";
        return;
      }
    } else {
      word[i] += ' ';
      bool found = 0;
      if (map1.find(word[i]) != map1.end()) {
        found = 1;
      }
      if (shift.size() == 0) found = 0;
      if (!found) {
        cout << -1 << "\n";
        return;
      }
      if (map1[word[i]] > p) hand++;
    }
  }
  cout << hand << "\n";
}
int main() { solve(); }
