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