#include <bits/stdc++.h>
using namespace std;
const int OO = 1000000000;
const int N = 100000 + 10;
int ans;
int m;
int n;
int a[N];
int b[N];
int cnt[N];
int f[N];
int root[N];
int min(int a, int b) { return a < b ? a : b; }
int find_root(int x) {
  int result = x;
  int temp;
  while (root[result] != result) result = root[result];
  while (x != result) {
    temp = root[x];
    root[x] = result;
    x = temp;
  }
  return result;
}
void unite(int v1, int v2) {
  int r1 = find_root(v1);
  int r2 = find_root(v2);
  if (r1 == r2) return;
  root[r2] = r1;
  cnt[r1] += cnt[r2];
}
void ri() {
  int cnte;
  int i;
  int v1;
  int v2;
  scanf("%d%d", &n, &cnte);
  for (i = 1; i <= n; i++) {
    root[i] = i;
    cnt[i] = 1;
  }
  while (cnte--) {
    scanf("%d%d", &v1, &v2);
    unite(v1, v2);
  }
  for (i = 1; i <= n; i++)
    if (find_root(i) == i) a[++m] = cnt[i];
  for (i = 1; i <= m; i++) b[a[i]]++;
}
bool lucky(int x) {
  while (x) {
    if (x % 10 != 4 && x % 10 != 7) return false;
    x /= 10;
  }
  return true;
}
void solve() {
  int i;
  int j;
  int k;
  f[0] = 0;
  for (i = 1; i <= n; i++) f[i] = OO;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= b[i]; j = j * 2)
      for (k = n; k >= i * j; k--) f[k] = min(f[k], f[k - i * j] + j);
  ans = OO;
  for (i = 1; i <= n; i++)
    if (lucky(i)) ans = min(ans, f[i]);
  if (ans == OO)
    ans = -1;
  else
    ans--;
}
void print() { printf("%d\n", ans); }
int main() {
  ri();
  solve();
  print();
  return 0;
}
