#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  k *= 2;
  vector<int> a(9, 0);
  char c;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      cin >> c;
      if (c != '.') {
        a[c - '1']++;
      }
    }
  }
  for (int i = 0; i < 9; ++i) {
    if (a[i] > k) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
