#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 12, INF = 1e9, lg = 20;
int n, m;
vector<int> ad[N];
int sz[N], cnt[N];
int dp[N], ans = INF;
bool ch(int a) {
  while (a) {
    if ((a % 10) != 4 && (a % 10) != 7) return 0;
    a /= 10;
  }
  return 1;
}
void dfs(int root) {
  sz[root] = 1;
  for (auto x : ad[root]) {
    if (sz[x]) continue;
    dfs(x);
    sz[root] += sz[x];
  }
  return;
}
int32_t main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    ad[u].push_back(v);
    ad[v].push_back(u);
  }
  for (int i = 1; i < N; i++) dp[i] = INF;
  for (int i = 0; i < n; i++) {
    if (sz[i]) continue;
    dfs(i);
    cnt[sz[i]]++;
  }
  dp[0] = -1;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] == 0) continue;
    for (int j = lg - 1; j >= 0; j--) {
      if (cnt[i] < (1 << j)) continue;
      int val = (1 << j) * i;
      for (int l = N; l >= val; l--) {
        if (dp[l - val] == INF) continue;
        dp[l] = min(dp[l], dp[l - val] + (1 << j));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!ch(i)) continue;
    ans = min(ans, dp[i]);
  }
  if (ans == INF) ans = -1;
  return cout << ans, 0;
}
