#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int n, k;
int main() {
scanf("%d", &n);
k = (2 * n) / 3;
printf("%d", k + 1);
printf("\n");
int y = 2 * k - n;
int x = n - 2 * y;
for (int i = 0; i <= y; i++) {
printf("%d %d %d", i, x + i, n - x - 2 * i);
printf("\n");
}
for (int i = 0; i < k - y; i++) {
printf("%d %d %d", y + i + 1, i, n - y - 1 - 2 * i);
printf("\n");
}
return 0;
}