#include <bits/stdc++.h>
using namespace std;
int nums[10];
int main() {
  int n;
  cin >> n;
  string temp;
  for (int i = 0; i < 4; ++i) {
    cin >> temp;
    for (int j = 0; j < 4; ++j) {
      if (temp[j] >= '0' || temp[j] <= '9') nums[temp[j] - '0']++;
    }
  }
  for (int k = 0; k < 10; ++k)
    if (2 * n < nums[k]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}
