#include <bits/stdc++.h>
using namespace std;
set<char> s;
vector<int> numbers;
vector<string> set1;
vector<string> set2;
vector<int> set3;
vector<int> wrong;
vector<pair<int, int> > points;
vector<pair<int, vector<string> > > ypairV;
pair<int, int> ypair;
string convertInt(int number) {
  if (number == 0) return "0";
  string temp = "";
  string returnvalue = "";
  while (number > 0) {
    temp += number % 10 + 48;
    number /= 10;
  }
  for (int i = 0; i < temp.length(); i++)
    returnvalue += temp[temp.length() - i - 1];
  return returnvalue;
}
int main() {
  int k;
  while (scanf("%d", &k) == 1) {
    char S[4][5];
    int count[10] = {0};
    bool ans = true;
    for (int i = 0; i < 4; i++) {
      scanf("%s", S[i]);
      for (int j = 0; j < 4; j++) {
        if (S[i][j] != '.') count[S[i][j] - '0']++;
      }
    }
    for (int i = 1; i <= 9; i++) {
      if (count[i] > k * 2) ans = false;
    }
    if (ans)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
