#include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 9223372036854775807;
const int Sz = 1110111;
using namespace std;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline void randomizer3000() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
int n, m;
bool used[Sz];
map<int, int> cnt;
int sz;
int dp[Sz];
vector<int> g[Sz];
bool lucky(int x) {
  while (x) {
    int d = x % 10;
    if (d != 4 && d != 7) return 0;
    x /= 10;
  }
  return 1;
}
void dfs(int v) {
  sz++;
  used[v] = 1;
  for (int to : g[v])
    if (!used[to]) dfs(to);
}
inline void add(int x, int cost) {
  for (int i = n - x; i >= 0; i--) {
    if (dp[i]) {
      if (!dp[i + x])
        dp[i + x] = dp[i] + cost;
      else
        dp[i + x] = min(dp[i + x], dp[i] + cost);
    }
  }
}
int main() {
  Read_rap();
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i);
      cnt[sz]++;
      sz = 0;
    }
  }
  dp[0] = 1;
  for (auto x : cnt) {
    for (int j = 1; j <= x.second; x.second -= j, j <<= 1) {
      add(j * x.first, j);
    }
    if (x.second) add(x.first * x.second, x.second);
  }
  int ans = MX;
  for (int i = 1; i <= n; i++) {
    if (lucky(i) && dp[i]) ans = min(ans, dp[i] - 2);
  }
  cout << (ans == MX ? -1 : ans);
  return 0;
}
