#include <bits/stdc++.h>
using namespace std;
int countd[11];
string s;
int k;
int main() {
  cin >> k;
  for (int i = 0; i < (4); i++) {
    cin >> s;
    for (int j = 0; j < (s.size()); j++)
      if (s[j] != '.') {
        int x = s[j] - '0';
        countd[x]++;
      }
  }
  for (int i = 1; i <= (9); i++) {
    if (countd[i] > 2 * k) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
