#include <bits/stdc++.h>
using namespace std;
vector<bool> was;
vector<vector<int> > g;
int dfs(int x) {
  if (was[x]) return 0;
  was[x] = true;
  int ans = 1;
  for (int i = 0; i < g[x].size(); ++i) {
    ans += dfs(g[x][i]);
  }
  return ans;
}
int good(int x) {
  while (x != 0) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  g = vector<vector<int> >(n);
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    g[l].push_back(r);
    g[r].push_back(l);
  }
  was = vector<bool>(n, false);
  vector<int> r;
  for (int i = 0; i < n; ++i) {
    int k = dfs(i);
    if (k != 0) r.push_back(k);
  }
  vector<int> a(100001, 0);
  for (int i = 0; i < r.size(); ++i) {
    ++a[r[i]];
  }
  vector<pair<int, int> > b;
  for (int i = 1; i < 100001; ++i) {
    int k = a[i];
    a[i] = 0;
    int cur = 1;
    while (cur <= k) {
      k -= cur;
      b.push_back(pair<int, int>(cur * i, cur));
      cur <<= 1;
    }
    if (k > 0) b.push_back(pair<int, int>(k * i, k));
  }
  vector<int> can(100001, 1e9);
  can[0] = 0;
  for (int i = 0; i < b.size(); ++i) {
    for (int j = 100000; j >= 0; --j)
      if (j + b[i].first <= 100000 &&
          can[j] + b[i].second < can[j + b[i].first])
        can[j + b[i].first] = can[j] + b[i].second;
  }
  int ans = 1e9;
  for (int i = 1; i < 100001; ++i) {
    if (can[i] && good(i)) {
      ans = min(ans, can[i]);
    }
  }
  if (ans == 1e9)
    cout << "-1";
  else
    cout << ans - 1;
  return 0;
}
