#include <bits/stdc++.h>
using namespace std;
long long int i, j, k;
int arr[100][100];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  int f[15] = {0};
  cin >> n;
  char x;
  int flag = 0;
  for (i = 0; i < 16; i++) {
    cin >> x;
    if (x == '.') {
      continue;
    } else {
      int temp = x - '0';
      f[temp]++;
      if (f[temp] > n * 2) flag = 1;
    }
  }
  if (flag == 1)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}
