#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, a[16], b = 0, c = 0;
  cin >> k;
  char p[4][4];
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> p[i][j];
      if (p[i][j] == '.') {
        a[b] = 0;
        c++;
      } else {
        a[b] = p[i][j] - 48;
      }
      b++;
    }
  }
  int d = 1, max = 1, e;
  sort(a, a + 16);
  e = a[c];
  if (c < 15) {
    for (int l = c + 1; l < 16; l++) {
      if (a[l] == e) {
        d++;
      } else if (a[l] != e) {
        e = a[l];
        d = 1;
      }
      if (d > max) {
        max = d;
      }
    }
  }
  if (max <= 2 * k) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
