#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  string s;
  cin >> k;
  vector<long long> cnt(10, 0);
  for (long long i = 0; i < 4; i++) {
    cin >> s;
    for (long long j = 0; s[j]; j++) {
      if (s[j] >= '0' && s[j] <= '9') cnt[s[j] - '0']++;
    }
  }
  for (long long i = 0; i < 10; i++) {
    if (cnt[i] > 2 * k) {
      cout << "NO";
      return;
    }
  }
  cout << "YES";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1, n, a, b, m;
  while (t--) solve();
  return 0;
}
