#include <bits/stdc++.h>
using namespace std;

const int N = 100010;
vector<int> v[N];
int n,m,x,y;
int q[N*2],head,tail;
bool pd[N];
void find(int x,int y){
//	cout<<x<<endl;
	int t;
	for(int i = 0;i<v[x].size();i++){
		t = v[x][i];
		if(!pd[t]){
			pd[t]=true;
			if(y==0)q[++tail] = t;
			else q[--head] = t;
			find(t,y);
			break;
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i =0;i<m;i++){
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	head = N;tail = N;
	q[head]  =1;
	pd[1]=true;
	find(1,0);
	find(1,1);
	printf("%d\n",tail-head+1);
	for(int i  =head;i<=tail;i++) printf("%d ",q[i]);puts("");
	return 0;
}