#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, p = 0;
  cin >> k;
  k = k * 2;
  vector<int> arr(9, 0);
  string a;
  for (int i = 0; i < 4; i++) {
    cin >> a;
    for (int j = 0; j < 4; j++) {
      if (a[j] != '.') {
        p = a[j] - '0';
        arr[p - 1]++;
      }
    }
  }
  int maxi = *max_element(arr.begin(), arr.end());
  if (maxi > k)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
