#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  k = 2 * k;
  char a[4][4];
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) cin >> a[i][j];
  int flag = 0;
  for (int i = 1; i < 10; i++) {
    int count = 0;
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 4; k++) {
        if (a[j][k] - '0' == i) {
          count++;
        }
      }
    }
    if (count > k) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "NO\n";
  else
    cout << "YES\n";
  return 0;
}
