// elagaz.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct adat
{
bool lat;
int tav;
vector <int> sz;
};
vector <int> v;
vector <adat> x;
long long n, i, m, a, b;
void mely(int csp, int kezd)
{
x[csp].lat = 1;
v.push_back(csp);
if (x[csp].sz.size() == 2)
{
for (auto& e : x[csp].sz)
{
if (x[e].lat == 0 && kezd!=e)
{
x[e].lat = 1;
mely(e, kezd);
}
}
}
}
int main()
{
cin >> n >> m;
x.resize(n + 1);
for (i = 1; i <= m; ++i)
{
cin >> a >> b;
x[a].sz.push_back(b);
x[b].sz.push_back(a);
}
for (i = 1; i <= n; ++i)
{
if (x[i].sz.size() == 1)
{
mely(x[i].sz[0], i);
}
}
cout << v.size() << "\n";
sort(v.begin(), v.end());
for (auto& e : v) cout << e << " ";
return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file