#include <bits/stdc++.h>
using namespace std;
char str[5][5];
int main() {
  int k, i, j;
  int cnt[10];
  while (cin >> k) {
    int flag = 0;
    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 4; i++) {
      cin >> str[i];
      for (j = 0; str[i][j]; j++) {
        if (str[i][j] >= '0' && str[i][j] <= '9') {
          cnt[str[i][j] - '0']++;
          if (cnt[str[i][j] - '0'] > 2 * k) flag = 1;
        }
      }
    }
    puts(flag ? "NO" : "YES");
  }
  return 0;
}
