#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, sqr = 350, inf = 1e9;
int n, m, dp[maxn], amount[maxn], ans = inf;
vector<int> v[maxn];
bool mark[maxn];
int dfs(int a) {
  mark[a] = 1;
  int sum = 1;
  for (int i = 0; i < v[a].size(); i++) {
    if (!mark[v[a][i]]) {
      sum += dfs(v[a][i]);
    }
  }
  return sum;
}
void lucky_generator(int a) {
  if (a > n) return;
  if (a) ans = min(ans, dp[a]);
  lucky_generator(a * 10 + 4);
  lucky_generator(a * 10 + 7);
}
int main() {
  scanf("%d %d", &n, &m);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    dp[i + 1] = inf;
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--, b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      amount[dfs(i)]++;
    }
  }
  for (int v = 1; v < n + 1; v++) {
    if (amount[v]) {
      int c = amount[v];
      int pw = 1;
      while (c) {
        if (c < pw) {
          pw = c;
        }
        c -= pw;
        for (int j = n; j >= pw * v; j--) {
          dp[j] = min(dp[j], dp[j - pw * v] + pw);
        }
        pw *= 2;
      }
    }
  }
  lucky_generator(0);
  if (ans == inf)
    printf("-1\n");
  else
    printf("%d\n", ans - 1);
}
