#include <bits/stdc++.h>
using namespace std;
char s[5][5];
int v[10];
int main() {
  int k;
  scanf("%d", &k);
  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] == '.') continue;
      v[s[i][j] - '0']++;
    }
  }
  int res = 0;
  for (int i = 1; i <= 9; i++) res = max(res, v[i]);
  if (res <= 2 * k)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
