#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pc[10] = {};
  cin >> n;
  char data[5];
  for (int i = 0; i < 4; i++) {
    cin >> data;
    for (int j = 0; j < 4; j++)
      if (data[j] >= '0' && data[j] <= '9') {
        pc[data[j] - '0']++;
      }
  }
  int f = 1;
  for (int i = 1; i <= 9; i++) {
    if (pc[i] > 2 * n) f = 0;
  }
  cout << (f ? "YES" : "NO") << endl;
  return 0;
}
