#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, inf = 1e6 + 10;
vector<int> adj[maxn];
vector<pair<int, int>> wg;
bool vis[maxn];
int n, m, dp[maxn], cnt[maxn];
bool lucky(int x) {
  while (x > 0) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
int bfs(int sorce) {
  vis[sorce] = true;
  int sum = 0;
  queue<int> q;
  q.push(sorce);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    sum++;
    for (auto u : adj[v]) {
      if (!vis[u]) {
        vis[u] = true;
        q.push(u);
      }
    }
  }
  return sum;
}
int main() {
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      int k = bfs(i);
      cnt[k]++;
    }
  }
  for (int i = 1; i <= 100000; i++) {
    if (cnt[i] > 0) {
      int x = 1;
      while (cnt[i] >= x) {
        cnt[i] -= x;
        wg.push_back({x * i, x});
        x *= 2;
      }
      if (cnt[i] > 0) wg.push_back({cnt[i] * i, cnt[i]});
    }
  }
  sort(wg.begin(), wg.end());
  dp[0] = 0;
  for (int i = 1; i <= 100000; i++) dp[i] = inf;
  for (int i = 0; i < wg.size(); i++) {
    auto p = wg[i];
    int x = p.first, y = p.second;
    for (int j = 100000; j >= 0; j--)
      if (j - x >= 0) dp[j] = min(dp[j], dp[j - x] + y);
  }
  int ans = inf;
  for (int i = 1; i <= 100000; i++) {
    if (lucky(i) && dp[i] > 0) ans = min(ans, dp[i]);
  }
  if (ans == inf)
    cout << -1;
  else
    cout << ans - 1;
  return 0;
}
