#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
int N, M;
vector<pair<int, int> > arr[200100];
bool vis[200100], e[200100];
struct ans {
  int a, b, c;
};
vector<ans> out;
void dfs(int node, int pa, int pind) {
  vis[node] = true;
  bool f = true;
  int one = -1;
  for (int i = 0; i < (int)arr[node].size(); i++) {
    if (!vis[arr[node][i].first]) {
      dfs(arr[node][i].first, node, arr[node][i].second);
    }
    if (arr[node][i].first != pa) {
      if (!e[arr[node][i].second] && f) {
        f = false;
        one = arr[node][i].first;
        e[arr[node][i].second] = true;
      }
      if (!e[arr[node][i].second] && !f) {
        f = true;
        e[arr[node][i].second] = true;
        out.push_back({one, node, arr[node][i].first});
      }
    }
  }
  if (!f && pa != -1 && !e[pind]) {
    e[pind] = true;
    out.push_back({one, node, pa});
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    arr[a].push_back({b, i});
    arr[b].push_back({a, i});
  }
  for (int i = 1; i <= N; i++) {
    if (!vis[i]) {
      dfs(i, -1, -1);
    }
  }
  printf("%d\n", (int)out.size());
  for (int i = 0; i < (int)out.size(); i++) {
    printf("%d %d %d\n", out[i].a, out[i].b, out[i].c);
  }
}
