#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) {
    int k, arr1[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    cin >> k;
    char arr[4][4];
    for (int i = 0; i <= 3; i++) {
      for (int j = 0; j <= 3; j++) {
        cin >> arr[i][j];
      }
    }
    for (int i = 0; i <= 3; i++) {
      for (int j = 0; j <= 3; j++) {
        if (arr[i][j] == '1') ++arr1[1];
        if (arr[i][j] == '2') ++arr1[2];
        if (arr[i][j] == '3') arr1[3]++;
        if (arr[i][j] == '4') arr1[4]++;
        if (arr[i][j] == '5') arr1[5]++;
        if (arr[i][j] == '6') arr1[6]++;
        if (arr[i][j] == '7') arr1[7]++;
        if (arr[i][j] == '8') arr1[8]++;
        if (arr[i][j] == '9') arr1[9]++;
      }
    }
    for (int i = 1; i <= 9; i++) {
      if (arr1[i] > 2 * k) {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES";
  }
  cerr << "Time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
