#include <bits/stdc++.h>
using namespace std;
const int N = 1 + 10;
int a[N];
int main() {
  int k;
  scanf("%d", &k);
  k *= 2;
  for (int i = 0; i < 4 - 1 + 1; i++)
    for (int j = 0; j < 4 - 1 + 1; j++) {
      char c;
      cin >> c;
      if (c != '.') {
        a[c - '0']++;
        if (a[c - '0'] > k) return printf("NO\n"), 0;
      }
    }
  return printf("YES\n"), 0;
}
