#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int k;
  cin >> k;
  unordered_map<int, int> m;
  for (size_t i = 0; i < 4; i++) {
    for (size_t j = 0; j < 4; j++) {
      char temp;
      cin >> temp;
      if (temp != '.') m[temp - '0']++;
    }
  }
  for (auto elm : m) {
    if (elm.second > 2 * k) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
