#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, cnt = 1;
  cin >> n;
  string a, s;
  for (i = 0; i < 16; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.begin() + 16);
  for (i = 0; i <= 16; i++) {
    if (s[i] == s[i + 1] && s[i] != '.')
      cnt++;
    else {
      if (cnt > n * 2) {
        cout << "NO" << endl;
        return 0;
      }
      cnt = 1;
    }
  }
  cout << "YES" << endl;
  return 0;
}
