#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[200005];
long long visited[200005];
unordered_map<long long, long long> mp;
long long dfs(long long cur) {
  long long ans = 1;
  visited[cur] = 1;
  for (auto u : adj[cur]) {
    if (!visited[u]) {
      ans += dfs(u);
    }
  }
  return ans;
}
bool islucky(long long x) {
  while (x) {
    if (x % 10 != 4 and x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long p, q;
    cin >> p >> q;
    adj[p].push_back(q);
    adj[q].push_back(p);
  }
  for (long long i = 1; i <= n; i++) {
    if (!visited[i]) mp[dfs(i)]++;
  }
  long long dp[n + 1];
  for (long long i = 0; i <= n; i++) dp[i] = n + 1;
  dp[0] = 0;
  for (auto u : mp) {
    long long i = u.first;
    long long tmp = u.second;
    long long cur = 1;
    while (tmp) {
      long long x = min(cur, tmp);
      tmp -= x;
      for (long long j = n; j >= i * x; j--) {
        dp[j] = min(dp[j], dp[j - i * x] + x);
      }
      cur <<= 1;
    }
  }
  long long ans = n + 1;
  for (long long i = 1; i <= n; i++) {
    if (islucky(i)) {
      ans = min(ans, dp[i]);
    }
  }
  if (ans == n + 1) {
    cout << "-1\n";
  } else
    cout << ans - 1 << "\n";
}
