#include <bits/stdc++.h>
using namespace std;
int cnt[10];
int main() {
  int k, n = 4;
  string s;
  cin >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < (int)s.size(); j++)
      if (s[j] >= '0' && s[j] <= '9') cnt[s[j] - '0']++;
  }
  bool flag = true;
  for (int i = 0; i < 10; i++)
    if (cnt[i] > 2 * k) flag = false;
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
