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