#include <bits/stdc++.h>
using namespace std;
int n, arr[10];
char c;
int main() {
  scanf("%d\n", &n);
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> c;
      if (c == '.') continue;
      arr[c - '0']++;
      if (arr[c - '0'] > 2 * n) {
        printf("NO\n");
        return 0;
      }
    }
  }
  printf("YES\n");
}
