#include <bits/stdc++.h>
using namespace std;
int main() {
  int flag[12], i, j, k, res;
  char a[6][6];
  while (scanf("%d", &k) == 1) {
    memset(flag, 0, sizeof(flag));
    res = 0;
    getchar();
    for (i = 0; i < 4; i++) {
      scanf("%s", &a[i]);
    }
    for (i = 0; i < 4; i++) {
      for (j = 0; j < 4; j++) {
        if (isdigit(a[i][j])) flag[a[i][j] - '0']++;
      }
    }
    for (i = 1; i <= 9; i++) {
      if (flag[i] <= k * 2)
        continue;
      else
        res = 1;
    }
    if (res)
      printf("NO\n");
    else
      printf("YES\n");
  }
  return 0;
}
