#include <bits/stdc++.h>
using namespace std;
long long ncr(int n, int r);
long long factorial(long long x);
long long power(long long x, long long y);
int main() {
  long long k;
  cin >> k;
  k *= 2;
  char arr[10][10] = {};
  long long freq[10] = {};
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 4; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == '.')
        continue;
      else {
        freq[arr[i][j] - '0']++;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    if (freq[i] > k) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
long long power(long long x, long long y) {
  long long h = 1;
  for (int i = 0; i < y; i++) {
    h = h * x;
  }
  return h;
}
long long factorial(long long x) {
  long long res = 1;
  for (int i = 1; i <= x; i++) {
    res = res * i;
  }
  return res;
}
long long ncr(int n, int r) {
  long long ans = 1;
  int rfact = 2;
  for (int i = n - r + 1; i <= n; i++) {
    ans *= i;
    if (ans % rfact == 0 && rfact <= r) {
      ans /= rfact;
      rfact++;
    }
    if (ans >= 1000000000 + 9) {
      ans = ans % (1000000009);
    }
  }
  return ans;
}
