import java.io.InputStream
import java.math.BigDecimal
import java.math.BigInteger
import java.util.*

fun main(args: Array<String>) = input.run {
    val n = nextInt()
    val m = nextInt()
    val nodes = Array<Node>(1 + n) { Node(it) }

    var s: Node = nodes[0]
    var t: Node = nodes[0]
    repeat(m) {
        val u = nodes[nextInt()]
        val v = nodes[nextInt()]
        u.adj.add(v)
        v.adj.add(u)
        s = u
        t = v
    }

    s.prev = t
    t.prev = s

    val start = go(s)
    go(t)

    val ans = ArrayList<Node>()

    var cur: Node? = start
    while (cur != null && cur != t) {
        ans.add(cur)
        cur = cur.prev
    }
    while (cur != null) {
        ans.add(cur)
        cur = cur.next
    }

    println(ans.size)
    println(ans.map { it.index }.joinToString(" "))
}

fun go(start: Node): Node {
    var cur = start
    while (true) {
        val next = cur.adj.find { it.prev == null } ?: return cur
        next.prev = cur
        cur.next = next
        cur = next
    }
}

class Node(val index: Int) {
    val adj = ArrayList<Node>()
    var prev: Node? = null
    var next: Node? = null
}

val input = FastScanner()

fun String.toBigInteger() = BigInteger(this)
fun String.toBigDecimal() = BigDecimal(this)

class FastScanner(private val input: InputStream = System.`in`) {
    private val sb = StringBuilder()
    private val buffer = ByteArray(4096)
    private var pos = 0
    private var size = 0

    fun nextString(): String? {
        var c = skipWhitespace()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            do {
                append(c.toChar())
                c = read()
            } while (c > ' '.toInt())

            toString()
        }
    }

    fun nextLine(): String? {
        var c = read()
        if (c < 0) return null

        return sb.run {
            setLength(0)

            while (c >= 0 && c != '\n'.toInt()) {
                append(c.toChar())
                c = read()
            }

            toString()
        }
    }

    fun nextLong(): Long {
        var c = skipWhitespace()

        val sign = if (c == '-'.toInt()) {
            c = read()
            -1
        } else 1

        var ans = 0L

        while (c > ' '.toInt()) {
            ans = ans * 10 + c - '0'.toInt()
            c = read()
        }

        return sign * ans
    }

    fun nextInt() = nextLong().toInt()
    fun nextDouble() = nextString()?.toDouble() ?: 0.0
    fun nextBigInteger(): BigInteger = nextString()?.toBigInteger() ?: BigInteger.ZERO
    fun nextBigDecimal(): BigDecimal = nextString()?.toBigDecimal() ?: BigDecimal.ZERO

    fun nextStrings(n: Int) = Array<String>(n) { nextString() ?: "" }
    fun nextInts(n: Int) = IntArray(n) { nextInt() }
    fun nextLongs(n: Int) = LongArray(n) { nextLong() }
    fun nextDoubles(n: Int) = DoubleArray(n) { nextDouble() }
    fun nextBigIntegers(n: Int) = Array<BigInteger>(n) { nextBigInteger() }
    fun nextBigDecimals(n: Int) = Array<BigDecimal>(n) { nextBigDecimal() }

    fun nextStrings(n: Int, m: Int) = Array(n) { nextStrings(m) }
    fun nextInts(n: Int, m: Int) = Array(n) { nextInts(m) }
    fun nextLongs(n: Int, m: Int) = Array(n) { nextLongs(m) }
    fun nextDoubles(n: Int, m: Int) = Array(n) { nextDoubles(m) }
    fun nextBigIntegers(n: Int, m: Int) = Array(n) { nextBigIntegers(m) }
    fun nextBigDecimals(n: Int, m: Int) = Array(n) { nextBigDecimals(m) }

    private fun skipWhitespace(): Int {
        while (true) {
            val c = read()
            if (c > ' '.toInt() || c < 0) return c
        }
    }

    private fun read(): Int {
        while (pos >= size) {
            if (size < 0) return -1
            size = input.read(buffer, 0, buffer.size)
            pos = 0
        }
        return buffer[pos++].toInt()
    }
}


Measured memory_bytes: 43452