#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100000], ans = 0;
  cin >> n;
  char s;
  for (int i = 0; i < 16; i++) {
    cin >> s;
    if (s == '.') {
      continue;
    } else {
      a[s]++;
    }
  }
  for (char i = '1'; i <= '9'; i++) {
    ans = max(a[i], ans);
  }
  if (ans <= 2 * n) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
