#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int v[200001], dp[2][200001];
vector<int> e[100001];
int flood(int x) {
  int ret = v[x] = 1;
  for (auto y : e[x])
    if (!v[y]) ret += flood(y);
  return ret;
}
bool islucky(int x) {
  if (x % 10 != 4 && x % 10 != 7) return false;
  return x >= 10 ? islucky(x / 10) : true;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  map<int, int> u;
  for (int i = 1; i <= n; i++)
    if (!v[i]) u[flood(i)]++;
  memset(dp, 63, sizeof(dp));
  int t = dp[0][0] = 0;
  for (auto x : u) {
    t ^= 1;
    for (int s = 0; s < x.first; s++) {
      queue<pair<int, int>> q;
      q.push({s, dp[t][s] = dp[1 - t][s]});
      for (int k = s + x.first; !q.empty(); k += x.first) {
        dp[t][k] = min(dp[1 - t][k],
                       q.front().second + (k - q.front().first) / x.first);
        if (q.front().first + x.first * x.second == k) q.pop();
        while (!q.empty() && dp[1 - t][k] <= q.front().second) q.pop();
        if (dp[1 - t][k] < INF) q.push({k, dp[1 - t][k]});
      }
    }
  }
  int ans = INF;
  for (int i = 0; i <= 100000; i++)
    if (dp[t][i] < ans && islucky(i)) ans = dp[t][i];
  if (ans != INF)
    printf("%d\n", ans - 1);
  else
    puts("-1");
}
