#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
int n, m, p[N];
vector<int> g[N], cur[N];
bool vis[N];
vector<pair<int, pair<int, int> > > ans;
void add(int a, int b, int c) {
  ans.push_back(make_pair(a + 1, pair<int, int>(b + 1, c + 1)));
  int idx = lower_bound((g[a]).begin(), (g[a]).end(), b) - g[a].begin();
  cur[a][idx] = 0;
  idx = lower_bound((g[c]).begin(), (g[c]).end(), b) - g[c].begin();
  cur[c][idx] = 0;
}
void dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < g[u].size(); ++i)
    if (!vis[g[u][i]]) {
      p[g[u][i]] = u;
      dfs(g[u][i]);
    }
  int id = -1;
  for (int i = 0; i < g[u].size(); ++i) {
    int t = g[u][i];
    if (t == p[u] || !cur[u][i]) continue;
    if (id == -1)
      id = t;
    else
      add(id, u, t), id = -1;
  }
  if (p[u] != -1 && id != -1) add(p[u], u, id);
}
int main() {
  cin >> n >> m;
  for (int a, b, i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
    cur[a].push_back(1);
    cur[b].push_back(1);
  }
  for (int i = 0; i < n; ++i) sort((g[i]).begin(), (g[i]).end());
  memset(p, -1, sizeof(p));
  for (int i = 0; i < n; ++i)
    if (!vis[i]) dfs(i);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i)
    printf("%d %d %d\n", ans[i].first, ans[i].second.first,
           ans[i].second.second);
}
