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