#include <bits/stdc++.h>
using namespace std;
long long c[10];
long long solve() {
  long long n;
  cin >> n;
  char a;
  for (long long i = 0; i < 4; ++i) {
    for (long long j = 0; j < 4; ++j) {
      cin >> a;
      if (a != '.') c[a - '0']++;
    }
  }
  for (long long i = 1; i <= 9; ++i) {
    if (c[i] > 2 * n) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
signed main() {
  ios::sync_with_stdio(false);
  long long t = 1;
  while (t--) solve();
  return 0;
}
