#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj(212345);
int visit[212345], dist[212345];
struct total {
  int a, b, c;
};
vector<total> vec;
int dfs(int cur, int par) {
  visit[cur] = 1;
  stack<int> st;
  if (par != -1) dist[cur] = dist[par] + 1;
  int i;
  for (i = 0; i < adj[cur].size(); i++) {
    if (!visit[adj[cur][i]]) {
      dfs(adj[cur][i], cur);
    }
    if (adj[cur][i] != par && dist[adj[cur][i]] < dist[cur]) {
      if (dist[adj[cur][i]] == -1) dist[adj[cur][i]] = (1000 * 1000 * 1000 + 5);
      st.push(adj[cur][i]);
      if (st.size() == 2) {
        int val1 = st.top();
        st.pop();
        int val2 = st.top();
        st.pop();
        total haha;
        haha.a = val1;
        haha.b = cur;
        haha.c = val2;
        vec.push_back(haha);
      }
    }
  }
  if (par == -1) {
    return 0;
  }
  if (st.size() == 1) {
    int val1 = st.top();
    st.pop();
    total haha;
    haha.a = val1;
    haha.b = cur;
    haha.c = par;
    vec.push_back(haha);
  } else {
    dist[cur] = -1;
  }
  return 0;
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int i, j, u, v;
  for (i = 0; i < m; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (i = 1; i < n + 1; i++) {
    if (!visit[i]) {
      dfs(i, -1);
    }
  }
  cout << vec.size() << endl;
  for (i = 0; i < vec.size(); i++) {
    cout << vec[i].a << " " << vec[i].b << " " << vec[i].c << endl;
  }
  return 0;
}
