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