#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10;
int n, m, w[N], head[N], nxt[N];
vector<int> e[N];
set<int> S[N];
void add(int f, int t) {
  static int cnt = 0;
  w[++cnt] = t;
  nxt[cnt] = head[f];
  head[f] = cnt;
  S[f].insert(t);
}
int size, q[N][3];
void print(int x, int y, int z) {
  size++;
  q[size][0] = x;
  q[size][1] = y;
  q[size][2] = z;
}
bool vis[N];
void dfs(int x, int fa) {
  vis[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    S[x].erase(w[i]);
    if (!vis[w[i]])
      dfs(w[i], x);
    else if (S[w[i]].count(x))
      e[x].push_back(w[i]);
  }
  for (int i = 1; i < e[x].size(); i += 2) print(e[x][i - 1], x, e[x][i]);
  if (!fa) return;
  if (e[x].size() & 1)
    print(fa, x, e[x][e[x].size() - 1]);
  else
    e[fa].push_back(x);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  printf("%d\n", size);
  for (int i = 1; i <= size; i++)
    printf("%d %d %d\n", q[i][0], q[i][1], q[i][2]);
  return 0;
}
