#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e17;
const long long MOD = 1000000007;
const long long MAX = 4000001;
const long double eps = 1E-14;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  }
  return b;
}
long long min(long long a, long long b) {
  if (a > b) {
    return b;
  }
  return a;
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  if (a < b) {
    return gcd(b, a);
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
struct edge {
  long long ind;
  long long fr;
  long long to;
  long long d;
};
class mint {
  long long x;

 public:
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint& a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint& a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint& a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint& a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint& a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint& a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint& operator/=(const mint& a) { return (*this) *= a.inv(); }
  mint operator/(const mint& a) const {
    mint res(*this);
    return res /= a;
  }
  friend ostream& operator<<(ostream& os, const mint& m) {
    os << m.x;
    return os;
  }
};
mint pw(mint a, long long b) {
  if (b == 0) {
    return 1;
  }
  mint ret = pw(a, b >> 1);
  ret *= ret;
  if (b & 1) {
    ret *= a;
  }
  return ret;
}
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> c(N, vector<long long>(N, 0));
  for (long long i = 1; i <= M; i++) {
    long long a, b, x;
    cin >> a >> b >> x;
    c[a - 1][b - 1] = x;
    c[b - 1][a - 1] = x;
  }
  vector<long long> con(1 << N, 0);
  for (long long t = 0; t < 1 << N; t++) {
    for (long long i = 0; i < N; i++)
      for (long long j = i + 1; j < N; j++) {
        if ((t >> i) & 1 && (t >> j) & 1) {
          con[t] += c[i][j];
        }
      }
  }
  vector<vector<long long>> dp(1 << N, vector<long long>(N, 0));
  for (long long t = 0; t < 1 << N; t++) {
    for (long long v = 0; v < N; v++) {
      if (!(t & 1)) {
        continue;
      }
      if (!((t >> v) & 1)) {
        continue;
      }
      if (v == 0) {
        dp[t][v] = con[t];
        continue;
      }
      for (long long u = t; u > 0; u = (u - 1) & t) {
        if (!(u & 1)) {
          continue;
        }
        if ((u >> v) & 1) {
          continue;
        }
        for (long long w = 0; w < N; w++) {
          if (((u >> w) & 1) && c[w][v] > 0) {
            long long now = dp[u][w] + c[w][v] + con[t & ~u];
            dp[t][v] = max(now, dp[t][v]);
          }
        }
      }
    }
  }
  long long all = 0;
  for (long long i = 0; i < N; i++)
    for (long long j = i + 1; j < N; j++) all += c[i][j];
  cout << all - dp[(1 << N) - 1][N - 1] << endl;
}
