#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 1e9 + 7;
vector<pair<int, int> > adjList[MAXN];
vector<pair<int, pair<int, int> > > ans;
bool visited[MAXN], used[MAXN];
int dist[MAXN];
void dfs(int start, int par) {
  visited[start] = true;
  int parind = -1;
  for (auto u : adjList[start]) {
    if (!visited[u.first]) {
      dist[u.first] = dist[start] + 1;
      dfs(u.first, start);
    }
    if (u.first == par) parind = u.second;
  }
  vector<int> vec;
  for (auto u : adjList[start])
    if (dist[u.first] > dist[start] && !used[u.second]) vec.push_back(u.first);
  for (int i = 0; i < max(0, (int)vec.size() - 1); i += 2)
    ans.push_back({vec[i], {start, vec[i + 1]}});
  if ((((int)vec.size()) & 1) && par != -1) {
    ans.push_back({vec.back(), {start, par}});
    used[parind] = true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int c, d;
    cin >> c >> d;
    adjList[c].push_back({d, i});
    adjList[d].push_back({c, i});
  }
  for (int i = 1; i <= n; ++i) {
    if (!visited[i]) {
      dfs(i, -1);
    }
  }
  cout << ans.size() << endl;
  for (auto u : ans)
    cout << u.first << " " << u.second.first << " " << u.second.second << endl;
}
