#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  vector<string> v;
  for (int i = 0; i < 4; i++) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  map<int, int> m;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      if ((v[i][j] - '0') > 0 && (v[i][j] - '0') <= 9) {
        m[v[i][j] - '0']++;
      }
    }
  }
  int flag = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    if ((it->second) > (2 * x)) {
      flag = 1;
      break;
    }
  }
  if (flag == 1)
    cout << "NO\n";
  else {
    cout << "YES\n";
  }
}
