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