#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 16;
int n, m, tot, sz, dp[N][1 << N], e[N][N], val[1 << N];  // val: 预处理每个联通块所有边的总值

void pre() {
    rep(s, 0, sz)
        rep(i, 1, n) if ((s >> (i - 1)) & 1)
            rep(j, i + 1, n) if ((s >> (j - 1)) & 1)
                val[s] += e[i][j];
}

void chkmax(int &x, int y) { x = max(x, y); }

int main() {
    cin >> n >> m;
    sz = (1 << n) - 1;
    rep(i, 1, m) {
        int x, y, z; scanf("%d%d%d", &x, &y, &z);
        e[x][y] = e[y][x] = z; tot += z;
    }
    pre();
    
    memset(dp, -1, sizeof(dp));
    dp[1][1] = 0;
    rep(s, 1, sz)
        rep(i, 1, n)
            if (((s >> (i - 1)) & 1) && dp[i][s] != -1) {
                rep(j, 1, n)
                    if (!((s >> (j - 1)) & 1) && e[i][j])
                        chkmax(dp[j][s | (1 << (j - 1))], dp[i][s] + e[i][j]);  // e[i][j] 作为桥边
                int S = (sz ^ s) | (1 << (i - 1));
                for (int j = S; j; j = (j - 1) & S)
                    if (j & (1 << (i - 1)))
                        chkmax(dp[i][s | j], dp[i][s] + val[j]);
            }
    printf("%d\n", tot - dp[n][sz]);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define gc() getchar()
inline int read(){int r=0,s=0,c=gc();for(;!isdigit(c);s=c,c=gc());for(;isdigit(c);(r*=10)+=c-48,c=gc());return s^45?r:-r;}
int f[16][32768], g[32768], w[16][16], n, E;
int main()
{
	n = read(), E = 1<<n; for(rint m = read(), a, b; m--; a = read()-1, b = read()-1, w[a][b] = w[b][a] = read()); for(rint i = 0; i < n; memset(f[i++],-1,E<<2));
	for(rint S = 1, T, i, j; S < E; S++) for(g[S] = g[T=S-(S&-S)], i = ilogb(S&-S), j = 0; j < n; j++) if(T&1<<j) g[S] += w[i][j]; f[0][1] = 0;
	for(rint S = 1, U = ~-E^1, T, i, j; S < E; S++, U = ~-E^S) for(i = 0; i < n; i++) if(f[i][S]>=0)
		{for(j = 0; j < n; w[i][j]&&U&1<<j?f[j][S|1<<j]=max(f[j][S|1<<j],f[i][S]+w[i][j]):0, j++); for(T = U; T; f[i][S|T] = max(f[i][S|T],f[i][S]+g[T|1<<i]), --T&=U);} printf("%d\n",g[~-E]-f[~-n][~-E]); return 0;
}