#include <cstdio>
using namespace std;
int main()
{
int k;
int cnt[10] = {0};
char mp[4][5];
scanf("%d", &k);
for (int i = 0; i < 4; i++){
scanf("%s", mp[i]);
for (int j = 0; j < 4; j++){
if (mp[i][j] == '.') continue;
else cnt[mp[i][j] - '0']++;
}
}
for (int i = 1; i <= 9; i++)
if (cnt[i] > 2 * k) return (!printf("NO\n"));
return (!printf("YES\n"));
}
I2luY2x1ZGUgPGNzdGRpbz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpCnsKICAgIGludCBrOwogICAgaW50IGNudFsxMF0gPSB7MH07CiAgICBjaGFyIG1wWzRdWzVdOwogICAgCiAgICBzY2FuZigiJWQiLCAmayk7CiAgICAKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKXsKICAgICAgICBzY2FuZigiJXMiLCBtcFtpXSk7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCA0OyBqKyspewogICAgICAgICAgICBpZiAobXBbaV1bal0gPT0gJy4nKSBjb250aW51ZTsKICAgICAgICAgICAgZWxzZSBjbnRbbXBbaV1bal0gLSAnMCddKys7CiAgICAgICAgfQogICAgfQogICAgCiAgICBmb3IgKGludCBpID0gMTsgaSA8PSA5OyBpKyspCiAgICAgICAgaWYgKGNudFtpXSA+IDIgKiBrKSByZXR1cm4gKCFwcmludGYoIk5PXG4iKSk7CiAgICAKICAgIHJldHVybiAoIXByaW50ZigiWUVTXG4iKSk7Cn0=