#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
vector<int> adj[100100];
bool vis[100100];
bool lucky[100100];
void lrek(int n) {
  int a1 = n * 10 + 4;
  int a2 = a1 + 3;
  if (a1 > 100000) return;
  lucky[a1] = true;
  lucky[a2] = true;
  lrek(a1);
  lrek(a2);
}
int rek1(int n) {
  if (vis[n]) return 0;
  vis[n] = true;
  int res = 1;
  for (__typeof__((adj[n]).begin()) it = (adj[n]).begin(); it != (adj[n]).end();
       it++)
    res += rek1(*it);
  return res;
}
int fbest;
int si[100100], A, N;
int dp[100100];
int gMin() {
  for (int i = (0); i < (A); i++)
    if (lucky[si[i]]) return 0;
  memset(dp, oo, sizeof(dp));
  dp[0] = 0;
  int to = 0;
  while (N > 0 && !lucky[N]) --N;
  if (N == 0) return -1;
  fbest = oo;
  for (int i = (0); i < (A); i++) {
    bool first = true;
    int nto = 0;
    for (int j = int(min(N + 1 - si[i], to + 1)) - 1; j >= (0); j--) {
      if (dp[j] < fbest) {
        nto += first * j;
        first = false;
        if (dp[j + si[i]] > dp[j] + 1) {
          dp[j + si[i]] = dp[j] + 1;
          if (lucky[j + si[i]]) fbest = min(fbest, dp[j] + 1);
        }
      }
    }
    to = nto + si[i];
  }
  fbest = oo;
  for (int i = (0); i < (N + 1); i++)
    if (lucky[i]) fbest = min(fbest, dp[i]);
  if (fbest == oo) return -1;
  return fbest - 1;
}
int main() {
  int M;
  memset(vis, false, sizeof(vis));
  memset(lucky, false, sizeof(lucky));
  scanf("%d%d", &N, &M);
  for (int i = (0); i < (N); i++) adj[i].clear();
  for (int i = (0); i < (M); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  lrek(0);
  fbest = oo;
  A = 0;
  for (int i = (0); i < (N); i++) {
    int cu = rek1(i);
    if (cu) si[A++] = cu;
  }
  sort(si, si + A);
  int res = gMin();
  cout << res << endl;
  return 0;
}
