#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int oo = 100000000;
vector<int> e[maxn];
int que[maxn], qid[maxn];
bool flag[maxn];
int cnt[maxn];
int A[maxn], B[maxn];
int opt[maxn], tmp[maxn];
int n, m, t;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0, a, b; i < m; i++) {
    scanf("%d%d", &a, &b);
    e[a].push_back(b);
    e[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!flag[i]) {
      int l = 1, r = 1;
      que[1] = i;
      flag[i] = 1;
      for (; l <= r; l++)
        for (int j = 0; j < e[que[l]].size(); j++)
          if (!flag[e[que[l]][j]]) {
            que[++r] = e[que[l]][j];
            flag[que[r]] = 1;
          }
      cnt[r]++;
    }
  for (int i = 1; i <= n; i++)
    if (cnt[i]) {
      A[++t] = i;
      B[t] = cnt[i];
    }
  for (int i = 1; i <= 77777; i++) opt[i] = oo;
  for (int i = 1; i <= t; i++) {
    for (int j = 0; j <= 77777; j++) tmp[j] = oo;
    for (int j = 0; j < A[i]; j++) {
      int l = 1, r = 0;
      for (int k = j, id = 0; k <= 77777; k += A[i], id++) {
        while (l <= r && id - qid[l] > B[i]) l++;
        if (l <= r) tmp[k] = que[l] + id;
        while (l <= r && opt[k] - id <= que[r]) r--;
        que[++r] = opt[k] - id;
        qid[r] = id;
      }
    }
    for (int j = 0; j <= 77777; j++) opt[j] = min(opt[j], tmp[j]);
  }
  int res = n + 1;
  for (int i = 1; i <= 77777; i++)
    if (opt[i] < res) {
      bool ok = 1;
      for (int k = i; k; k /= 10) ok &= (k % 10 == 4 || k % 10 == 7);
      if (ok) res = opt[i];
    }
  if (res == n + 1)
    printf("-1\n");
  else
    printf("%d\n", res - 1);
}
