#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
bool fla, fla2;
int arr[10];
int main() {
  int k;
  char ch;
  scanf("%d", &k);
  k *= 2;
  for (int i = 0; i < 16; ++i) {
    cin >> ch;
    if (ch == '.') continue;
    ++arr[ch - 48];
  }
  for (int i = 1; i <= 9; ++i) {
    if (arr[i] > k) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
  return 0;
}
