#include <bits/stdc++.h>
using namespace std;
const int row = 101;
int arr[row];
inline long long power(int x, int n) {
  if (n == 0) return 1;
  return (x * power(x, n - 1));
}
inline long long GCD(long long a, long long b) {
  if (a > b) swap(a, b);
  if (a == 0)
    return b;
  else
    return GCD(a, b % a);
}
inline bool isprime(long long x) {
  bool f = true;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) {
      f = false;
      break;
    }
  return f;
}
int main() {
  int n;
  cin >> n;
  n *= 2;
  char ar[4][4];
  int mx = 0;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) {
      cin >> ar[i][j];
      if (isdigit(ar[i][j])) mx = max(mx, ar[i][j] - '0');
    }
  vector<int> v(mx + 1);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (isdigit(ar[i][j])) v[ar[i][j] - '0']++;
  for (int i = 0; i < v.size(); i++)
    if (v[i] > n) {
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
  return 0;
}
