#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  int x, k;
  char c;
  cin >> k;
  for (int i = 0; i < 16; i++) {
    cin >> c;
    if (c == '.') continue;
    x = int(c) - 48;
    a[x]++;
  }
  bool r = true;
  for (int i = 0; i < 10; i++) {
    if (2 * k >= a[i])
      r = true;
    else {
      r = false;
      break;
    }
  }
  if (r) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
