#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int main() {
  int k;
  scanf("%d", &k);
  int x[10];
  memset(x, 0, sizeof(x));
  char s[5];
  for (auto i = 0; i < 4; i++) {
    scanf("%s", s);
    for (auto j = 0; j < 4; j++) {
      if (s[j] == '.') {
        continue;
      }
      x[s[j] - '0']++;
    }
  }
  for (auto i = 1; i < 10; i++) {
    if (x[i] > 2 * k) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
