#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, d = 0, e = 0, f = 0, sum = 0, c = 0, n;
  cin >> n;
  char a[4][4];
  map<int, int> m;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      if (a[i][j] >= 49 && a[i][j] <= 57) {
        m[a[i][j]]++;
      }
    }
  }
  for (auto x : m) {
    if (x.second > (2 * n)) {
      c++;
    }
  }
  if (c == 0) {
    cout << "YES";
  } else
    cout << "NO";
}
