#include <bits/stdc++.h>
using namespace std;
vector<int> ans, e[200010];
int done[200010], dp[200010];
void push(int a, int b, int c) {
  ans.push_back(a);
  ans.push_back(b);
  ans.push_back(c);
}
void dfs(int v, int p = -1) {
  done[v] = 1;
  int pa = -1;
  for (int i = 0; i < e[v].size(); i++) {
    int w = e[v][i];
    if (!done[w]) {
      dfs(w);
    } else if (done[w] == 1) {
      continue;
    }
    int r = dp[w];
    if (r != -1) {
      push(r, w, v);
      dp[w] = -1;
    } else if (pa != -1) {
      push(pa, v, w);
      pa = -1;
    } else {
      pa = w;
    }
  }
  done[v] = 2;
  dp[v] = pa;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, x;
    scanf("%d%d", &u, &x);
    --u;
    --x;
    e[u].push_back(x);
    e[x].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (!done[i]) {
      dfs(i);
    }
  }
  printf("%d\n", ans.size() / 3);
  for (int i = 0; i < ans.size(); i++) {
    printf("%d%c", ans[i] + 1, i % 3 == 2 ? '\n' : ' ');
  }
  return 0;
}
