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