#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[10] = {0};
  char k;
  int n;
  cin >> n;
  for (int i = 0; i < 16; i++) {
    cin >> k;
    if (k != '.') arr[k - '0']++;
  }
  for (int i = 1; i < 10; i++) {
    if (arr[i] > n * 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
