#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename T>
T MOD(T a, T m) {
  a %= m;
  if (a < 0) a += m;
  return a;
}
template <typename T>
T inverse(T a, T m) {
  a = MOD(a, m);
  if (a <= 1) return a;
  return MOD((1 - inverse(m, a) * m) / a, m);
}
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
namespace SOLVE {
template <int maxn>
struct dsu {
  int f[maxn];
  dsu() { init(); }
  void init() { memset(f, -1, sizeof(f)); }
  int fa(int c) {
    if (f[c] < 0) return c;
    return f[c] = fa(f[c]);
  }
  void merge(int a, int b) {
    a = fa(a);
    b = fa(b);
    if (a == b) return;
    if (f[a] < f[b]) swap(a, b);
    f[b] += f[a];
    f[a] = b;
  }
  bool same(int a, int b) { return fa(a) == fa(b); }
};
dsu<100010> bcj;
int cnt[100010];
int is_lucky[100010];
int cost[100010];
void main() {
  long long n, m;
  in(n, m);
  for (long long i = 0; i < m; i++) {
    int u, v;
    in(u, v);
    bcj.merge(u, v);
  }
  for (long long i = 1; i < n + 1; i++) {
    if (bcj.f[i] < 0) {
      cnt[-bcj.f[i]]++;
    }
  }
  is_lucky[4] = is_lucky[7] = 1;
  for (long long i = 10; i < 100010; i++) {
    is_lucky[i] = is_lucky[i / 10] and (i % 10 == 4 or i % 10 == 7);
  }
  memset(cost, 0x3f, sizeof(cost));
  cost[0] = 0;
  for (long long i = 1; i < 100010; i++) {
    for (int j = 1; j <= cnt[i]; j *= 2) {
      for (int k = 100000; k >= j * i; k--) upmin(cost[k], cost[k - j * i] + j);
      cnt[i] -= j;
    }
    int j = cnt[i];
    if (j)
      for (int k = 100000; k >= j * i; k--) upmin(cost[k], cost[k - j * i] + j);
  }
  int ans = -1;
  for (long long i = 1; i < 100010; i++) {
    if (cost[i] < 100010 and is_lucky[i]) {
      if (ans == -1 or ans > cost[i] - 1) ans = cost[i] - 1;
    }
  }
  cout << ans << endl;
}
}  // namespace SOLVE
signed main() {
  int t = 1;
  while (t--) {
    SOLVE::main();
  }
  return 0;
}
