#include <bits/stdc++.h>
using namespace std;
constexpr long long int MOD = 1000000007;
constexpr double EPS = 1e-8;
long long int N, M, K, H, W, L, R;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  vector<int> v(10);
  for (int i = 0; i < 4; i++) {
    string s;
    cin >> s;
    for (auto j : s) {
      if (j >= '0' && j <= '9') {
        v[j - '0']++;
      }
    }
  }
  for (int i = 0; i < 10; i++) {
    if (v[i] > N * 2) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}
