#include <bits/stdc++.h>
typedef long long ll;

const int MAX_N = 1e6;
const int INF = 1e9;

std::vector<int> len[MAX_N];
std::vector<std::pair<int, int>> ans;

bool viz[MAX_N];

int main () {

    int n, m;
    std::cin>>n>>m;

    for( int i=0 ; i<m ; i++ ){
        int a, b;
        std::cin>>a>>b;
        a--; b--;
        len[a].push_back(i);
        len[b].push_back(i);
    }

    int num = 0;
    for( int i=0 ; i<n ; i++ ){
        if( len[i].size() == 2 ){
            if( !viz[len[i][0]] and !viz[len[i][0]] ){
                ans.push_back({ len[i][0], len[i][1] });
                viz[len[i][0]] = true;
                viz[len[i][1]] = true;
                num ++;
            }
        }
    }

    std::cout<<num<<"\n";
    for( auto j : ans )
        std::cout<<j.first+1<<" "<<j.second+1<<"\n";

    return 0;
}
