#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, w = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') ch = getchar(), w = -1;
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + ch - 48, ch = getchar();
  return x * w;
}
const int N = 1e5 + 5;
const int INF = 1 << 30;
int n, m;
int fa[N], siz[N], cnt[N], f[N];
int ans = INF;
inline int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline void merge(int x, int y) {
  int fx = find(x);
  int fy = find(y);
  fa[fx] = fy;
}
inline bool check(int num) {
  while (num) {
    if ((num % 10) != 4 && (num % 10) != 7) return 0;
    num /= 10;
  }
  return 1;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1, u, v; i <= m; i++) {
    u = read(), v = read();
    merge(u, v);
  }
  for (int i = 1; i <= n; i++) siz[find(i)]++;
  for (int i = 1; i <= n; i++) cnt[siz[i]]++;
  std::fill(f + 1, f + 1 + n, 1 << 30);
  f[0] = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > 0) {
      int now = cnt[i];
      for (int p = 1; now > 0; p <<= 1) {
        p = std::min(p, now);
        now -= p;
        int w = p * i;
        for (int j = n - w; j >= 0; j--) {
          f[j + w] = std::min(f[j + w], f[j] + p);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++)
    if (check(i)) ans = std::min(ans, f[i]);
  if (ans != INF)
    printf("%d\n", --ans);
  else
    puts("-1");
  return 0;
}
