#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 0x3f3f3f3f;   const long long llinf = 1e18;   const long long nax = 0;   int n, m, batas;   vector<pair<int, int>> shift;   set<char> simpen;   map<char, bool> sabi;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> n >> m >> batas;     char arr[n + 5][m + 5];     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cin >> arr[i][j];         if (arr[i][j] ==  S ) {           shift.push_back({i, j});         } else {           simpen.insert(arr[i][j]);         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         for (auto x : shift) {           int x1 = i, x2 = x.first, y1 = j, y2 = x.second;           int hitung = ceil(sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)));           if (hitung <= batas) {             sabi[arr[i][j]] = 1;           }         }       }     }     int q, ans = 0;     cin >> q;     string s;     cin >> s;     for (int k = 0; k < q; ++k) {       if (s[k] >= 97) {         if (!simpen.count(s[k])) {           cout <<  -1  <<   n ;           return 0;         } else           continue;       } else {         if (shift.empty()) {           cout <<  -1  <<   n ;           return 0;         }         bool ok = 0, ada = 0;         if (!simpen.count(s[k] + 32)) {           cout <<  -1  <<   n ;           return 0;         } else {           if (sabi[s[k] + 32])             continue;           else             ans++;         }       }     }     cout << ans <<   n ;   }   