#include <bits/stdc++.h>
using namespace std;
const int MAX = 0x7FFFFFFF;
const int MIN = 0x80000000;
int main() {
  int k, num[10];
  char a[4][4];
  memset(num, 0, sizeof(num));
  cin >> k;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++) {
      cin >> a[i][j];
      if (a[i][j] != '.') num[a[i][j] - '0']++;
    }
  int flag = 0;
  for (int i = 1; i <= 9; i++)
    if (2 * k < num[i]) {
      flag = 1;
      break;
    }
  if (flag == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
