#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[5][5];
  int n, flag = 0, i, j;
  map<char, int> f;
  scanf("%d", &n);
  for (i = 1; i <= 4; i++) {
    getchar();
    for (j = 1; j <= 4; j++) {
      scanf("%c", &a[i][j]);
      if (a[i][j] >= '1' && a[i][j] <= '9') {
        f[a[i][j]]++;
      }
    }
  }
  map<char, int>::iterator it;
  for (it = f.begin(); it != f.end(); it++) {
    if (it->second > 2 * n) {
      flag = 1;
    }
  }
  if (flag == 0) {
    printf("YES\n");
  } else
    printf("NO\n");
}
