#include <bits/stdc++.h>
using namespace std;
int n, k, cnt[200004], visited[200004], ret;
vector<int> v;
int main(){
    cin >> n >> k;
    visited[n] = 1;
    queue<int> q;
    q.push(n);
    
    while(q.size()){
        int here = q.front();
        q.pop();
        
        if(here == k){
            ret = visited[here];
            break;
        }
        for(int next : {here + 1, here - 1, here * 2}){
            if(next >= 0 && next <= 200000){
                if(!visited[next]){
                    q.push(next);
                    visited[next] = visited[here] + 1;
                    cnt[next] = here;
                }                
            }
        }
    }
    
    for(int i = k; i != n; i = cnt[i]){
        v.push_back(i);
    }
    v.push_back(n);
    
    cout << ret - 1 << '\n';
    for(int a : v){
        cout << a << ' ';
    }
}