#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long b, long long p, long long m) {
  if (p == 0) return 1;
  long long my = bigmod(b, p / 2, m);
  my *= my;
  my %= m;
  if (p & 1) my *= b, my %= m;
  return my;
}
long long setb(long long n, long long pos) { return n = n | (1 << pos); }
long long resb(long long n, long long pos) { return n = n & ~(1 << pos); }
bool checkb(long long n, long long pos) { return (bool)(n & (1 << pos)); }
vector<int> g[200005];
int ed[200005][2];
int n, m;
bool visit[200005];
vector<int> ans;
void Push(int u, int v, int w) {
  ans.push_back(u);
  ans.push_back(v);
  ans.push_back(w);
}
int Fuck_This_Shit(int u) {
  visit[u] = 1;
  int len = g[u].size(), i;
  vector<int> lol;
  for (i = 0; i < len; i++) {
    int v = g[u][i];
    if (visit[v] == 0) lol.push_back(v);
  }
  vector<int> shit;
  for (i = 0; i < lol.size(); i++) {
    int v = lol[i];
    int w = Fuck_This_Shit(v);
    if (w)
      Push(u, v, w);
    else
      shit.push_back(v);
  }
  int s = (shit.size() / 2) * 2;
  for (int i = 0; i < s; i += 2) {
    int v = shit[i];
    int w = shit[i + 1];
    Push(v, u, w);
  }
  if (s != shit.size()) return shit[shit.size() - 1];
  return 0;
}
int main() {
  int i;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &ed[i][0], &ed[i][1]);
    g[ed[i][0]].push_back(ed[i][1]);
    g[ed[i][1]].push_back(ed[i][0]);
  }
  for (i = 1; i <= n; i++) {
    if (visit[i] == 0) {
      Fuck_This_Shit(i);
    }
  }
  printf("%d\n", (int)ans.size() / 3);
  for (int i = 0; i < ans.size(); i += 3) {
    printf("%d %d %d\n", ans[i], ans[i + 1], ans[i + 2]);
  }
  return 0;
}
