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