#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string s;
  vector<int> p(10, 0);
  for (int i = 0; i < 4; i++) {
    cin >> s;
    for (int j = 0; j < 4; j++)
      if (s[j] != '.') p[s[j] - '0']++;
  }
  for (int i = 1; i <= 9; i++) {
    if (p[i] > 2 * k) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
