#include <bits/stdc++.h>
using namespace std;
char b[4][5];
int k;
int main() {
  scanf("%d", &k);
  int c[10] = {0};
  for (int i = 0; i < 4; i++) {
    scanf("%s", b[i]);
    for (int j = 0; j < 4; j++) {
      if (b[i][j] != '.') c[b[i][j] - '0']++;
    }
  }
  int res = 0;
  for (int i = 1; i <= 9; i++) {
    if (c[i] > res) res = c[i];
  }
  if (res > 2 * k)
    puts("NO");
  else
    puts("YES");
  return 0;
}
