#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<int, int> i_i;
 
const int MOD = 1e9 + 7;
const ll INF = LLONG_MAX / 2;
 
 
int main() {
	int N, M; cin >> N >> M;
	vector<int> a(M), b(M), c(M);
	rep(i, M) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
	vector<vector<int> > adj(N, vector<int>(N));
	rep(i, M) adj[a[i]][b[i]] = adj[b[i]][a[i]] = c[i];
	
	vector<int> C(1<<N);
	rep(S, 1<<N) rep(i, M) if ((S>>a[i] & 1) && (S>>b[i] & 1)) C[S] += c[i];
	vector<vector<int> > dp(1<<N, vector<int>(N, -1));
	dp[1][0] = 0;
	rep(S, 1<<N) rep(u, N) if (dp[S][u] != -1) {
		int _S = (1<<N) - 1 - S;
		rep(v, N) if ((_S>>v & 1) && adj[u][v])
			dp[S | 1 << v][v] = max(dp[S | 1 << v][v], dp[S][u] + adj[u][v]);
		for (int T = _S; T; T = (T - 1) & _S)
			dp[S | T][u] = max(dp[S | T][u], dp[S][u] + C[T | 1<<u]);
	}
	int ans = -dp.back()[N - 1];
	rep(i, M) ans += c[i];
	cout << ans << endl;
}
