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