#include <bits/stdc++.h>
using namespace std;
const long long MXN = 1e6 + 1;
const long long MOD = 1e9 + 7;
void free() {
  freopen("txt.in", "r", stdin);
  freopen("txt.out", "w", stdout);
}
char s[101][101];
long long n;
map<char, int> m;
int main() {
  cin >> n;
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 4; j++) {
      cin >> s[i][j];
      m[s[i][j]]++;
    }
  }
  for (int i = 1; i <= 9; i++) {
    if (m[i + '0'] > n * 2) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
