#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 * 1000 + 100;
const int oo = 1000 * 1000 * 1000;
int n, m;
vector<int> adj[maxn];
int comp[maxn], cm = 0;
bool mark[maxn];
pair<int, int> num[maxn];
int sz = 0;
int dp[2][maxn], last[2][maxn], t[2][maxn];
void dfs(int v) {
  mark[v] = true;
  comp[cm]++;
  for (int u : adj[v])
    if (!mark[u]) dfs(u);
}
void knapsack() {
  for (int i = 0; i < sz; i++)
    for (int j = 0; j <= n; j++) {
      int ind = i % 2;
      if (i)
        dp[ind][j] = dp[1 - ind][j], last[ind][j] = last[1 - ind][j],
        t[ind][j] = t[1 - ind][j];
      if (j >= num[i].first) {
        if (i && dp[1 - ind][j - num[i].first] + 1 < dp[ind][j]) {
          dp[ind][j] = dp[1 - ind][j - num[i].first] + 1;
          last[ind][j] = i;
          t[ind][j] = 1;
        }
        if (dp[ind][j - num[i].first] + 1 >= dp[ind][j]) continue;
        if (last[ind][j - num[i].first] != i) {
          dp[ind][j] = dp[ind][j - num[i].first] + 1;
          t[ind][j] = 1;
          last[ind][j] = i;
          continue;
        }
        if (t[ind][j - num[i].first] + 1 > num[i].second) continue;
        t[ind][j] = t[ind][j - num[i].first] + 1;
        dp[ind][j] = dp[ind][j - num[i].first] + 1;
      }
    }
}
bool chk(int num) {
  if (num == 0) return false;
  while (num) {
    if (num % 10 != 4 && num % 10 != 7) return false;
    num /= 10;
  }
  return true;
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  fill(last[0], last[0] + n + 1, -1);
  fill(t[0], t[0] + n + 1, 0);
  fill(dp[0], dp[0] + n + 1, oo);
  dp[0][0] = 0;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 0; i < n; i++)
    if (!mark[i]) {
      dfs(i);
      cm++;
    }
  sort(comp, comp + cm);
  for (int i = 0; i < cm; i++) {
    num[sz] =
        pair<int, int>(comp[i], upper_bound(comp, comp + cm, comp[i]) -
                                    lower_bound(comp, comp + cm, comp[i]));
    i = upper_bound(comp, comp + cm, comp[i]) - comp;
    i--;
    sz++;
  }
  knapsack();
  int ans = oo;
  for (int i = 1; i <= n; i++)
    if (chk(i)) {
      ans = min(ans, dp[(sz - 1) % 2][i]);
    }
  if (ans == oo) ans = 0;
  ans--;
  cout << ans << endl;
  return 0;
}
