// Namori
// * frank_c1
// * 2017 / 12 / 18
 
#include <bits/stdc++.h>
using namespace std;

const int maxn = (int)(1e5) + 5;
vector<int> nxt[maxn];
int fa[maxn], dfn[maxn], siz[maxn];
int cnt;

void dfs(int x, int f) {
	fa[x] = f; siz[x] = 1; dfn[x] = ++idx;
	for (int i = 0; i < (int)nxt[x].size(); ++i)
		if (nxt[x][i] != f) {
			if (!dfn[nxt[x][i]]) {
				dfs(nxt[x][i], x);
				siz[x] += siz[nxt[x][i]];
			} else if (dfn[nxt[x][i]] < dfn[x]) {
				cnt = 1;
				int c = x, a = nxt[x][i];
				while (c != a) {
					++cnt; c = fa[c];
				}
			}
		}
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		nxt[u].push_back(v); nxt[v].push_back(u);
	}
	dfs(1, 0);
	if (!cnt) {
		if (n & 1) {
			printf("-1\n");
		} else {
			int ret = 0;
			for (int i = 1; i <= n; ++i) ret += (siz[i] & 1);
			printf("%d\n", ret);
		}
	} else if (!(cnt & 1)) {
		
	} else {
		
	}
	return 0;
}