#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, a[10] = {0};
  cin >> k;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) {
      char x;
      cin >> x;
      if (x == '.') x = '0';
      a[x - '0']++;
    }
  for (int i = 1; i <= 9; i++) {
    if (a[i] > k * 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
