#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  map<int, int> mp;
  cin >> k;
  for (int i = 1; i <= 16; i = i + 1) {
    char x;
    cin >> x;
    if (x != '.') mp[x - '0']++;
  }
  string res = "YES";
  for (auto u : mp) {
    if (u.second > 2 * k) {
      res = "NO";
      break;
    }
  }
  cout << res;
  return 0;
}
