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