#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, next;
};
bool islucky[100010];
bool vis[100010];
int A[100010], C[100010];
edge e[2 * 100010];
int beg[100010], f[100010];
int n, m, cnt, tot, ne;
void dfs(int x) {
  if (x >= 100010) return;
  islucky[x] = true;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
void pre_cal() {
  memset(islucky, 0, sizeof(islucky));
  dfs(0);
  islucky[0] = false;
}
void dfs2(int x) {
  vis[x] = true;
  cnt++;
  for (int i = beg[x]; i != -1; i = e[i].next)
    if (!vis[e[i].v]) {
      dfs2(e[i].v);
    }
}
void add(int x, int y) {
  e[ne].v = y;
  e[ne].next = beg[x];
  beg[x] = ne++;
}
void input() {
  int x, y;
  ne = 0;
  memset(beg, 255, sizeof(beg));
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  memset(vis, 0, sizeof(vis));
  memset(C, 0, sizeof(C));
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      cnt = 0;
      dfs2(i);
      C[cnt]++;
    }
  tot = 0;
  for (int i = 1; i <= n; i++)
    if (C[i]) {
      A[tot] = i;
      C[tot++] = C[i];
    }
}
void dp() {
  fill(f, f + n + 1, 0x3fffffff);
  f[0] = 0;
  for (int j = 0; j < tot; j++) {
    int num = C[j];
    int k = 0;
    for (k = 0; (1 << k) <= num; k++) {
      for (int i = n; i >= (1 << k) * A[j]; i--)
        f[i] = min(f[i], f[i - (1 << k) * A[j]] + (1 << k));
      num -= (1 << k);
    }
    if (num > 0)
      for (int i = n; i >= num * A[j]; i--)
        f[i] = min(f[i], f[i - num * A[j]] + num);
  }
  int ans = 0x3fffffff;
  for (int i = 1; i <= n; i++)
    if (islucky[i] && f[i] < ans) ans = f[i];
  if (ans == 0x3fffffff)
    printf("-1\n");
  else
    printf("%d\n", ans - 1);
}
int main() {
  pre_cal();
  while (scanf("%d%d", &n, &m) != EOF) {
    input();
    dp();
  }
  return 0;
}
