#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[10] = {0};
  int k;
  cin >> k;
  k *= 2;
  char s;
  for (int i = 0; i < 16 && cin >> s; i++)
    if (s != '.') arr[s - '0']++;
  for (int i = 0; i < 10; i++)
    if (arr[i] > k) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
