#include <bits/stdc++.h>
using namespace std;
void sol() {
  int n;
  cin >> n;
  char arr[4][4];
  int c = 0;
  int num[9];
  for (int i = 0; i < 9; i++) num[i] = 0;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> arr[i][j];
      if (arr[i][j] != '.') {
        num[(arr[i][j] - '0') - 1]++;
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if (num[i] > 2 * n) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
  return;
}
int main() {
  sol();
  return 0;
}
