#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, s, y, k, n;
  scanf("%d", &n);
  char a[10][10];
  for (i = 0; i < 4; i++) cin >> a[i];
  y = 0;
  for (k = 0; k <= 9; k++) {
    s = 0;
    for (i = 0; i < 4; i++)
      for (j = 0; j < 4; j++) {
        if ((a[i][j] - '0') == k) {
          s++;
        }
      }
    if (s > n * 2) {
      y = 1;
      break;
    }
  }
  if (y == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
