#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  int count[10] = {0};
  char c;
  cin >> k;
  for (int i = 0; i < 16; ++i) {
    cin >> c;
    if (c >= '1' && c <= '9') {
      count[c - '0']++;
    }
  }
  for (int i = 1; i < 10; ++i) {
    if (count[i] > 2 * k) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
