#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, flag = 0, i, j;
  char a[5][5];
  cin >> n;
  map<int, int> mp;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      cin >> a[i][j];
      if (a[i][j] == '.')
        continue;
      else
        mp[a[i][j] - '0']++;
    }
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it->second > 2 * n) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}
