#include <bits/stdc++.h>
using namespace std;
int n, m;
bool vis[100015];
int cnt[100015], dp[100015];
bool check(int x) {
  while (x) {
    if ((x % 10) != 4 && (x % 10) != 7) return 0;
    x /= 10;
  }
  return 1;
}
namespace UF {
int fa[100015], siz[100015];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void uni(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;
  fa[u] = v;
  siz[v] += siz[u];
}
}  // namespace UF
using namespace UF;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) siz[i] = 1, fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    uni(u, v);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[find(i)]) continue;
    vis[find(i)] = 1;
    cnt[siz[find(i)]]++;
  }
  memset(dp, 0x3f3f3f3f, sizeof dp);
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    int x = 1;
    while (cnt[i] > x) {
      for (int j = n; j >= x * i; j--) dp[j] = min(dp[j], dp[j - x * i] + x);
      cnt[i] -= x;
      x <<= 1;
    }
    if (cnt[i] > 0) {
      for (int j = n; j >= cnt[i] * i; j--)
        dp[j] = min(dp[j], dp[j - cnt[i] * i] + cnt[i]);
    }
  }
  int ans = 0x3f3f3f3f;
  for (int i = 1; i <= n; i++)
    if (check(i)) {
      ans = min(ans, dp[i]);
    }
  printf("%d\n", ans == 0x3f3f3f3f ? -1 : ans - 1);
  return 0;
}
