#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  cin >> k;
  k *= 2;
  int cnt[10];
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < 4; i++) {
    string s;
    cin >> s;
    for (char c : s)
      if (c != '.') cnt[c - '0']++;
  }
  bool cant = count_if(cnt, cnt + 10, [&](int x) { return x > k; });
  cout << (cant ? "NO" : "YES");
}
