#include <bits/stdc++.h>
using namespace std;
int fr[10];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, i, j;
  char ch;
  cin >> n;
  for (i = 1; i <= 4; i++)
    for (j = 1; j <= 4; j++) {
      cin >> ch;
      fr[ch - 48]++;
    }
  for (i = 0; i <= 9; i++)
    if (fr[i] > n * 2) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
