#include <bits/stdc++.h>
using namespace std;
int main() {
  map<char, int> Mp;
  int k;
  cin >> k;
  k <<= 1;
  Mp['.'] = 1;
  char c;
  for (int i = 0; i <= 9; i++) {
    c = '0' + i;
    Mp[c] = 0;
  }
  int m = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> c;
      Mp[c]++;
      if ((Mp[c] > m) and (c != '.')) {
        m = Mp[c];
      }
    }
  }
  if (m <= k) {
    puts("YES");
  } else {
    puts("NO");
  }
}
