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