#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5 + 10;
long long n, m, t, ans = 1e13;
long long cnt[MXN], dp[MXN];
vector<long long> adj[MXN], A, Val;
bool vis[MXN];
void dfs(long long u) {
  vis[u] = 1, t++;
  for (auto v : adj[u]) {
    if (!vis[v]) dfs(v);
  }
}
bool Lucky(long long x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) return 0;
    x /= 10;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, 63, sizeof dp);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) t = 0, dfs(i), cnt[t]++;
  }
  for (int i = 1; i < MXN; i++) {
    if (!cnt[i]) continue;
    long long p = 1;
    while (p <= cnt[i]) {
      A.push_back(p * i), Val.push_back(p);
      cnt[i] -= p;
      p *= 2;
    }
    if (cnt[i]) A.push_back(cnt[i] * i), Val.push_back(cnt[i]);
  }
  n = A.size();
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = MXN - 1; j >= A[i]; j--) {
      dp[j] = min(dp[j], dp[j - A[i]] + Val[i]);
    }
  }
  for (int i = 4; i < MXN; i++) {
    if (Lucky(i)) ans = min(ans, dp[i]);
  }
  cout << (ans == 1e13 ? -1 : ans - 1);
  return 0;
}
