#include <bits/stdc++.h>
using namespace std;
int panels[10];
string l1, l2, l3, l4;
bool possible = true;
int main() {
  int k;
  cin >> k;
  cin >> l1;
  cin >> l2;
  cin >> l3;
  cin >> l4;
  string t = l1 + l2 + l3 + l4;
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == '1') panels[1]++;
    if (t[i] == '2') panels[2]++;
    if (t[i] == '3') panels[3]++;
    if (t[i] == '4') panels[4]++;
    if (t[i] == '5') panels[5]++;
    if (t[i] == '6') panels[6]++;
    if (t[i] == '7') panels[7]++;
    if (t[i] == '8') panels[8]++;
    if (t[i] == '9') panels[9]++;
  }
  for (int i = 1; i < 10; i++) {
    if (panels[i] > 2 * k) possible = false;
  }
  if (possible)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
