#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k;
  scanf("%lld", &k);
  map<long long int, long long int> mp;
  for (long long int i = 0; i < 4; i++) {
    for (long long int j = 0; j < 4; j++) {
      char c;
      cin >> c;
      mp[c - '0']++;
    }
  }
  for (long long int i = 1; i <= 9; i++) {
    long long int p = 2 * k;
    if (mp[i] > p) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
