#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 10, M = 2e5 + 100, MOD = 1e9 + 7;
int cnt[M], vis[M], mo = 0, dp[4][M], n;
vector<int> adj[M], ve;
int dfs(int v) {
  vis[v] = 1;
  int x = 1;
  for (int u : adj[v])
    if (!vis[u]) x += dfs(u);
  return x;
}
bool ch(int x) {
  while (x) {
    if (x % 10 != 7 && x % 10 != 4) return 0;
    x /= 10;
  }
  return 1;
}
void f(int &x, int i, int y) {
  x ^= 1;
  for (int j = 0; j <= n; j++) {
    dp[x][j] = dp[x ^ 1][j];
    if (y * i <= j) dp[x][j] = min(dp[x][j], dp[x ^ 1][j - y * i] + y);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) mo++, cnt[dfs(i)]++;
  }
  int x = 0, ans = INF;
  for (int i = 0; i <= n; i++) dp[0][i] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    if (!cnt[i]) continue;
    int y = 1;
    while (y < cnt[i]) {
      f(x, i, y);
      cnt[i] -= y;
      y *= 2;
    }
    f(x, i, cnt[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (ch(i)) ans = min(ans, dp[x][i]);
  }
  if (ans == INF)
    cout << -1;
  else
    cout << ans - 1;
}
