#include <bits/stdc++.h>
using namespace std;
int main() {
  char arr[4][4];
  int sum, fin;
  cin >> fin;
  cin.ignore();
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      sum = 0;
      if (arr[i][j] == '.') continue;
      for (int k = 0; k < 4; k++) {
        for (int l = 0; l < 4; l++) {
          if (arr[k][l] == arr[i][j]) sum++;
        }
      }
      if (sum > fin * 2) break;
    }
  }
  if (sum > fin * 2)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
