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