#include <bits/stdc++.h>
using namespace std;
int top;
int add[1100];
int value[1100];
void split(int v, int left) {
  int m = 1;
  while (m * 2 <= left) {
    add[top] = v * m;
    value[top] = m;
    top++;
    m *= 2;
  }
  m /= 2;
  while (m) {
    left -= m;
    m /= 2;
  }
  add[top] = v * left;
  value[top] = left;
  top++;
}
int cnt[101000];
int region[101000];
int father[101000];
int dp[101000];
int ancestor(int v) {
  if (father[v] == v) return v;
  return father[v] = ancestor(father[v]);
}
bool islucky(int v) {
  while (v)
    if (v % 10 != 4 && v % 10 != 7)
      return false;
    else
      v /= 10;
  return true;
}
int main() {
  int n, m;
  int u, v;
  int ancu, ancv;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) father[i] = i;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    ancu = ancestor(u - 1);
    ancv = ancestor(v - 1);
    if (ancu != ancv) father[ancu] = ancv;
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) cnt[ancestor(i)]++;
  memset(region, 0, sizeof(region));
  for (int i = 0; i < n; i++)
    if (cnt[i] != 0) region[cnt[i]]++;
  top = 0;
  for (int i = 1; i <= n; i++)
    if (region[i] != 0) split(i, region[i]);
  for (int i = 0; i <= n; i++) dp[i] = n + 1;
  dp[0] = 0;
  for (int i = 0; i < top; i++)
    for (int j = n; j >= add[i]; j--)
      dp[j] = min(dp[j], dp[j - add[i]] + value[i]);
  int res = n + 1;
  for (int i = 4; i <= n; i++)
    if (islucky(i)) res = min(res, dp[i]);
  if (res > n)
    printf("-1\n");
  else
    printf("%d\n", res - 1);
  return 0;
}
