#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
using v = vector<T>;
const ll N = 1e5;
const ll INF = numeric_limits<ll>::max() / 2;
bool islucky(ll n) {
  if (n <= 0) {
    return false;
  }
  while (n > 0) {
    ll mod = n % 10;
    if (mod != 4 && mod != 7) {
      return false;
    }
    n /= 10;
  }
  return true;
}
int main(int argc, char const* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  ll n, m, x, y;
  scanf("%lld %lld", &n, &m);
  v<unordered_set<ll>> adj(n + 1);
  for (ll i = 0; i < m; i++) {
    scanf("%lld %lld", &x, &y);
    if (x != y) {
      adj[x].insert(y);
      adj[y].insert(x);
    }
  }
  v<bool> marked(n + 1);
  unordered_map<ll, ll> valcnt;
  for (ll i = 1; i <= n; i++) {
    if (!marked[i]) {
      marked[i] = true;
      ll cursize = 1;
      queue<ll> qu;
      qu.push(i);
      while (!qu.empty()) {
        ll curnode = qu.front();
        qu.pop();
        for (ll neigh : adj[curnode]) {
          if (!marked[neigh]) {
            cursize++;
            marked[neigh] = true;
            qu.push(neigh);
          }
        }
      }
      valcnt[cursize]++;
    }
  }
  v<ll> best(n + 1, INF);
  best[0] = 0;
  for (const auto& vc : valcnt) {
    const ll a = vc.first;
    const ll c = vc.second;
    ll pow = 1;
    ll bound = (c + 1) / 2;
    for (; pow <= bound; pow <<= 1) {
      for (ll i = n; i >= pow * a; i--) {
        best[i] = min(best[i], pow + best[i - pow * a]);
      }
    }
    ll rem = (c - pow + 1);
    for (ll i = n; i >= rem * a; i--) {
      best[i] = min(best[i], rem + best[i - rem * a]);
    }
  }
  ll minislands = INF;
  for (ll i = 1; i <= n; i++) {
    if (islucky(i)) {
      minislands = min(minislands, best[i]);
    }
  }
  if (minislands == INF) {
    printf("-1\n");
  } else {
    printf("%lld\n", minislands - 1);
  }
  return 0;
}
