k, 33 bytes =========== {1+&x=+\{(#$x;4;8)+/~3 5!'x}'1+!x}