#include <bits/stdc++.h>
using namespace std;
const int MX = 25;
int main(int argc, char *argv[]) {
  int k;
  cin >> k;
  string a[4];
  for (int i = (0), _b = (4); i < (_b); ++i) cin >> a[i];
  int cnt[10] = {0};
  for (int i = (0), _b = (4); i < (_b); ++i)
    for (int j = (0), _b = (4); j < (_b); ++j)
      if (a[i][j] != '.') cnt[a[i][j] - '0']++;
  for (int i = (0), _b = (10); i < (_b); ++i) cnt[i] -= 2 * k;
  for (int i = (0), _b = (10); i < (_b); ++i)
    if (cnt[i] > 0) {
      cout << "NO\n";
      return 0;
    }
  cout << "YES\n";
  return 0;
}
