#include <bits/stdc++.h>
using namespace std;
double tick() {
  static clock_t oldt, newt = clock();
  double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
  oldt = newt;
  return diff;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long a[4][4] = {0};
  long long k;
  cin >> k;
  char c;
  std::map<long long, long long> mp;
  for (long long i = 0LL; i < (4); i++)
    for (long long j = 0LL; j < (4); j++) {
      cin >> c;
      if (c != '.') mp[c - '0']++;
    }
  bool flag = true;
  for (auto a : mp)
    if (a.second > (2 * k)) {
      flag = false;
      break;
    }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
