#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  int arr[10]{};
  for (int i = 0; i < 16; i++) {
    char c;
    cin >> c;
    int t = c - 48;
    arr[t]++;
  }
  sort(arr, arr + 10);
  if (arr[9] > 2 * k)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
