#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char a;
  int ar[9] = {0};
  string s;
  vector<string> v;
  for (int i = 0; i < 4; i++) {
    cin >> s;
    for (int j = 0; j < 4; j++) {
      if ('1' <= s[j] && s[j] <= '9') {
        ar[s[j] - '1']++;
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    if (ar[i] > 2 * n) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
