#include <bits/stdc++.h>
using namespace std;
template <class T>
T mod_f(T num) {
  if (num >= 0)
    return num % 1000000007;
  else
    return ((num % 1000000007) + 1000000007) % 1000000007;
}
template <class T>
T fast_pow(T b, T p) {
  if (p == 0) return 1;
  if (p % 2) {
    T x = mod_f(mod_f(b) * mod_f(fast_pow(b, p - 1)));
    return x;
  } else {
    T x = mod_f(fast_pow(b, p / 2));
    x = mod_f(mod_f(x) * mod_f(x));
    return x;
  }
}
template <class T>
T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    T r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  int sz = v.size() - 1;
  for (int i = 0; i <= sz; i++) out << v[i] << " ";
  return out;
}
template <class T>
ostream& operator,(ostream& out, T a) {
  out << a << " ";
  return out;
}
bool isEqual(double a, double b) { return fabs(a - b) <= 1e-9; }
bool isLessThan(double a, double b) { return a + 1e-9 < b; }
bool isLessThanEqual(double a, double b) { return a < b + 1e-9; }
bool isGreaterThan(double a, double b) { return a > b + 1e-9; }
bool isGreaterThanEqual(double a, double b) { return a + 1e-9 > b; }
int cnt[10], mx;
int main() {
  int i, j, k;
  char ch;
  cin >> k;
  for (i = 1; i <= 4; i++) {
    for (j = 1; j <= 4; j++) {
      cin >> ch;
      if (isdigit(ch)) ++cnt[ch - 48];
    }
  }
  for (i = 1; i <= 9; i++) mx = max(mx, cnt[i]);
  if (mx <= 2 * k)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
