#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <time.h>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
//#define Graph vector<vector<int>>

#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
class Graph {
public:
	int vn;
	int sumcost = 0;
	vector<vector<pii>> g;

	Graph(int n) {
		vn = n;
		g.resize(n);
	}
	virtual void con(int a, int b, int w) = 0;
	int getWeight(int f, int t) {
		auto itr = lower_bound(ALL(g[f]), make_pair(t, INT_MIN));
		if (itr != g[f].end())
			return itr->second;
		return INT_MIN;
	}
	int Costsum() {
		return sumcost;
	}
};
class BiDGraph : public Graph {//無向
public:
	BiDGraph(int n) : Graph(n) {}

	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		g[b].push_back({ a, w });
		sumcost++;
	}
	void scan(int edcount, bool oindexed = 0) {
		REP(i, edcount) {
			int a, b;
			scanf("%d %d", &a, &b);
			con(a - oindexed, b - oindexed);
		}
	}
};
class DGraph : public Graph {//有向
public:
	DGraph(int n) : Graph(n) {}
	void con(int a, int b, int w = 1) {
		g[a].push_back({ b,w });
		sumcost++;
	}
};

//Lowlink  BID
void Lowlink(BiDGraph& g, vector<int>& lowlink, DGraph& dfsg, vector<int>& orb, int st = 0) {
	orb.clear();
	lowlink.clear();
	orb.resize(g.vn, INT_MAX);
	lowlink.resize(g.vn, INT_MAX);
	int k = 0;
	function<void(int, int)> dfs = [&](int cur, int f) {
		int nex = 0;
		orb[cur] = k++;
		lowlink[cur] = orb[cur];
		for (auto itr : g.g[cur]) {
			if (f == itr.first) { f = -1; continue; }
			if (orb[itr.first] == INT_MAX) {
				dfs(itr.first, cur);
				lowlink[cur] = min(lowlink[cur], lowlink[itr.first]);
				dfsg.con(cur, itr.first);
			}
			else {
				lowlink[cur] = min(lowlink[cur], orb[itr.first]);
			}
		}
	};
	dfs(st, -1);
	return;
}
signed main() {
	int n, m;
	scanf("%d %d", &n, &m);

	BiDGraph g(n);
	DGraph dg(n);
	g.scan(m,1);
	vector<int> low,orb;
	Lowlink(g, low, dg, orb);

	int st = 0;
	int gr = 0;
	rep(i, 1, n) {
		if (st == 0 && low[i] != orb[i])
			st = i;
	}

	REP(i, n) {
		if (g.g[i].size() == 1)
		st = i;
	}

	vector<int> al(n);
	bool end = 0;
	Lowlink(g, low, dg, orb, st);
	vector<int> ans;
	function<void(int, int)> dfs = [&](int cur, int f) {
		al[cur] = 1;
		ans.push_back(cur+1);
		for (auto itr : g.g[cur]) {
			if (low[itr.first] == low[st] && al[itr.first] == 0 && !end) {
				dfs(itr.first, cur);
			}
		}
		if (!end) {
			for (auto itr : g.g[cur]) {
				if ( al[itr.first] == 0 && !end) {
					dfs(itr.first, cur);
				}

			}
		}
		end = 1;
	};
	dfs(st, -1);
	printf("%d\n", ans.size());
	REP(i, ans.size()) {
		printf("%d",ans[i]);
		if (i != ans.size() - 1)
			printf(" ");

	}
	printf("\n");
 	return 0; }


Measured memory_bytes: 25980