#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int Days[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int read() {
  int ans = 0;
  bool f = 1;
  char ch = getchar();
  while (!isdigit(ch)) f ^= ch == '-', ch = getchar();
  while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = getchar();
  return f ? ans : -ans;
}
int pre[100010], sz[100010];
int cnt[100010];
int DP[100010];
int n, m;
int FindRoot(int x) { return (x == pre[x] ? x : pre[x] = FindRoot(pre[x])); }
void Union(int x, int y) { pre[FindRoot(x)] = FindRoot(y); }
bool islucky(int x) {
  int t = x;
  while (t) {
    if (t % 10 != 4 && t % 10 != 7) return 0;
    t /= 10;
  }
  return 1;
}
void dp(int x, int y) {
  for (int i = n; i >= x; i--) DP[i] = min(DP[i], DP[i - x] + y);
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) pre[i] = i;
  for (int i = 1; i <= n; i++) DP[i] = 1000000007;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Union(x, y);
  }
  for (int i = 1; i <= n; i++) sz[FindRoot(i)]++;
  for (int i = 1; i <= n; i++) cnt[sz[i]]++;
  for (int i = 1; i <= n; i++)
    if (cnt[i]) {
      for (int j = 1; j <= cnt[i]; j <<= 1) dp(i * j, j), cnt[i] -= j;
      dp(i * cnt[i], cnt[i]);
    }
  int ans = 1000000007;
  for (int i = 1; i <= n; i++)
    if (islucky(i)) ans = min(ans, DP[i]);
  printf("%d", (ans == 1000000007 ? -1 : ans - 1));
  return 0;
}
