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