#include <bits/stdc++.h>
using namespace std;
int d[10] = {};
int main() {
  int k;
  cin >> k;
  for (int x = 0; x < 4; x++) {
    for (int y = 0; y < 4; y++) {
      char a;
      cin >> a;
      if (a != '.') {
        d[a - '0']++;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    ans = max(ans, d[i]);
  }
  cout << (ans <= 2 * k ? "YES" : "NO") << endl;
}
