#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, count = 0, b[10] = {0}, k, flag = 0;
  cin >> n;
  char a[4][4];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      cin >> a[i][j];
      k = int(a[i][j] - 48);
      b[k]++;
    }
  }
  for (i = 0; i < 10; i++) {
    if (b[i] != 0) {
      if (b[i] > 2 * n) {
        flag = 1;
        break;
      }
    }
  }
  if (flag == 0) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
