#include <bits/stdc++.h>
using namespace std;
string ar[4];
int n, a[10];
int main() {
  cin >> n;
  for (int i = 0; i < 4; ++i) cin >> ar[i];
  n <<= 1;
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j)
      if (isdigit(ar[i][j])) a[ar[i][j] - '0']++;
  bool ans = 1;
  for (int i = 0; i < 9; ++i)
    if (a[i + 1] > n) ans = 0;
  cout << (ans ? "YES" : "NO") << endl;
  return 0;
}
