#include <bits/stdc++.h>#include <bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
signed main() {
int n,m;
cin >> n >> m;
i64 ans = 0;
i64 sum = 0;
if ( m%2 == 0 ) {
for ( int i = 0 ; i < m ; i++ ) {
int u,v,w;
cin >> u >> v >> w;
sum += w;
}
ans = sum;
} else {
priority_queue<array<int,3>,vector<array<int,3>>,greater<>>q;
vector g(n,vector<pair<int,int>>(0));
for ( int i = 0 ; i < m ; i++ ) {
int u,v,w;
cin >> u >> v >> w;
u--,v--;
g[u].emplace_back(v,w);
g[v].emplace_back(u,w);
sum += w;
q.push({w,u,v});
}
vector<int>dfn(n);
vector<int>low(n);
map<pair<int,int>,pair<int,int>>mp;
int idx = 0;
auto tarjan = [&](auto& tarjan, int u, int f )->int{
dfn[u] = low[u] = ++idx;
int res = 0;
for ( auto [v,w] : g[u] ) {
if ( v == f ) continue;
res++;
if ( !dfn[v] ) {
int t = tarjan(tarjan,v,u);
low[u] = min(low[u],low[v]);
if ( dfn[u] < low[v] ) {
mp[{u,v}] = {1,t};
mp[{v,u}] = {1,t};
}
res += t;
} else {
low[u] = min(low[u],dfn[v]);
}
}
return res;
};
tarjan(tarjan,0,-1);
while ( q.size() ) {
auto [w,u,v] = q.top();
q.pop();
if ( mp[{u,v}].first == 1 ) {
// cout << u << ' ' << v << ' ' << mp[{u,v}].second << '\n';
if ( (mp[{u,v}].second)%2 == 0 ) {
ans = sum-w;
break;
}
} else {
ans = sum-w;
break;
}
}
}
cout << ans << '\n';
}
using namespace std;
using i64 = long long;
int main() {
int n,m;
cin >> n >> m;
i64 ans = 0;
i64 sum = 0;
if ( m%2 == 0 ) {
for ( int i = 0 ; i < m ; i++ ) {
int u,v,w;
cin >> u >> v >> w;
sum += w;
}
ans = sum;
} else {
queue<array<int,3>>q;
vector g(n,vector<pair<int,int>>(0));
for ( int i = 0 ; i < m ; i++ ) {
int u,v,w;
cin >> u >> v >> w;
u--,v--;
g[u].emplace_back(v,w);
g[v].emplace_back(u,w);
sum += w;
q.push({w,u,v});
}
vector<int>dfn(n);
vector<int>low(n);
map<pair<int,int>,pair<int,int>>mp;
int idx = 0;
auto tarjan = [&](auto& tarjan, int u, int f )->int{
dfn[u] = low[u] = ++idx;
int res = 0;
for ( auto [v,w] : g[u] ) {
if ( v == f ) continue;
res++;
if ( !dfn[v] ) {
int t = tarjan(tarjan,v,u);
low[u] = min(low[u],low[v]);
if ( dfn[u] < low[v] ) {
mp[{u,v}] = {1,t};
mp[{v,u}] = {1,t};
}
res += t;
} else {
low[u] = min(low[u],dfn[v]);
}
}
return res;
};
tarjan(tarjan,0,-1);
while ( q.size() ) {
auto [w,u,v] = q.front();
q.pop();
if ( mp[{u,v}].first == 1 ) {
// cout << u << ' ' << v << ' ' << mp[{u,v}].second << '\n';
if ( mp[{u,v}].second%2 == 0 ) {
ans = max(sum-w,ans);
}
} else {
ans = max(sum-w,ans);
}
}
}
cout << ans << '\n';
}