/*
 * AOJ 1312: Where's Wally
 * ?¢?????????????w*h????????¢????????????????????????Base64?????????????¬????????????????????????¢????????????Base64??¬??????????????¶??????????±????01??¨????????¢???????????\?????¢????????¬????????¬????????\???????±?????????°????°???????
 * ?±???????????¬????+??????
 * ??????????°???????Base64???????????¬??????????????¶????????¢???????????¬?????¬?????°8???????????????????????????????????????hash???????????????hash?????????hash?????¨?????\?????§?????????????????????????????¨hash?????????????????????
 */


#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef unsigned long long ULL;  // ??¢????????????????¨?

char mat[200];
ULL bg[1010][1010], sm[110][110], tm[110][110];
ULL h[1010];
ULL pattern[8];

const ULL B = 100000007ull;
const ULL C = 100000009ull;

void Decode(ULL *a) {
  int len = (int) strlen(mat);
  for (int i = 0; i < len; ++i) {
    char ch = mat[i];
    int x = 0;
    if (ch >= 'A' && ch <= 'Z') {
      x = ch - 'A';
    } else if (ch >= 'a' && ch <= 'z') {
      x = ch - 'a' + 26;
    } else if (ch >= '0' && ch <= '9') {
      x = ch - '0' + 52;
    } else if (ch == '+') {
      x = 62;
    } else if (ch == '/') {
      x = 63;
    }
    for (int j = 6 * i + 5; j >= 6 * i; --j) {
      a[j] = (ULL)x & 1;
      x >>= 1;
    }
  }
}

int Find(ULL x) {
  for (int i = 0; i < 8; ++i) {
    if (pattern[i] == x) {
      return i;
    }
  }
  return -1;
}

int main() {
  int m, n, p;
  while (scanf("%d%d%d", &n, &m, &p) != EOF && m) {
    int ans = 0;
    for (int i = 0; i < m; ++i) {
      scanf("%s", mat);
      Decode(bg[i]);
    }
    for (int i = 0; i < p; ++i) {
      scanf("%s", mat);
      Decode(sm[i]);
    }

//    for (int i = 0; i < m; ++i) {
//      for (int j = 0; j < n; ++j) printf("%lld", bg[i][j]);
//      printf("\n");
//    }
//
//    for (int i = 0; i < p; ++i) {
//      for (int j = 0; j < p; ++j) printf("%d", sm[i][j]);
//      printf("\n");
//    }

    ULL bs = 1ull, cs = 1ull;
    for (int i = 0; i < p; ++i) {
      bs *= B;
      cs *= C;
    }

    for (int k = 0; k < 8; ++k) {
      for (int i = 0; i < p; ++i) {
        for (int j = 0; j < p; ++j) {
          tm[j][p - 1 - i] = sm[i][j];
        }
      }
      if (k == 4) {
        for (int i = 0; i < p; ++i) {
          for (int j = 0; j < p; ++j) {
            tm[i][p - 1 - j] = sm[i][j];
          }
        }
      }

//      for (int i = 0; i < p; ++i) {
//        for (int j = 0; j < p; ++j) printf("%lld", tm[i][j]);
//        printf("\n");
//      }
//      printf("----k=%d\n", k);

      ULL x = 0ull;
      for (int i = 0; i < p; ++i) {
        ULL y = 0ull;
        for (int j = 0; j < p; ++j) {
          y = y * B + tm[i][j];
        }
        x = x * C + y;
      }
      pattern[k] = x;
      memcpy(sm, tm, sizeof(tm));
    }

    for (int i = 0; i < m; ++i) {
      ULL x = 0ull;
      for (int j = 0; j < p; ++j) {
        x = x * B + bg[i][j];
      }
      h[i] = x;
    }

    for (int j = p; j <= n; ++j) {
      ULL x = 0ull;
      for (int i = 0; i < p; ++i) {
        x = x * C + h[i];
      }
      for (int i = p; i <= m; ++i) {
        if (Find(x) >= 0) {
          ++ans;
//          printf("%d %d find %d\n",i,j,Find(x));
        }
        if (i == m) break;
        x = x * C - h[i - p] * cs + h[i];
      }
      if (j == n) break;
      for (int i = 0; i < m; ++i) {
        h[i] = h[i] * B - bs * bg[i][j - p] + bg[i][j];
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 10764