#include <bits/stdc++.h>
using namespace std;
int n, m, p[100009], cnt[100009], vis[100009], dp[100009], a[100009], tot;
int findset(int x) { return x == p[x] ? x : p[x] = findset(p[x]); }
void unionset(int x, int y) { p[findset(x)] = findset(y); }
bool luck(int x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) return 0;
    x /= 10;
  }
  return 1;
}
int solve(int m) {
  int ans = 1e9;
  for (int i = 1; i <= n; i++) dp[i] = 1e9;
  for (int i = 1; i <= m; i++) {
    int cur = cnt[i];
    for (int p = 1; cur > 0; p <<= 1) {
      p = min(p, cur);
      cur -= p;
      for (int j = n; j >= p * a[i]; j--)
        dp[j] = min(dp[j], dp[j - p * a[i]] + p);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (luck(i)) {
      ans = min(ans, dp[i]);
    }
  }
  if (ans == 1e9) return -1;
  return ans - 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    unionset(u, v);
  }
  for (int i = 1; i <= n; i++) cnt[findset(i)]++;
  for (int i = 1; i <= n; i++) {
    if (i == p[i]) vis[cnt[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) {
      tot++;
      a[tot] = i;
      cnt[tot] = vis[i];
    }
  }
  printf("%d\n", solve(tot));
  return 0;
}
