let str; while(str = readline()){ if(str !== '0') { let num = parseInt(str); console.log(dp(num)); } }
function dp(num) { if(num == 2) { return 1; }else if(num == 1 || num == 0) { return 0; } else { return parseInt(num/3) + dp(parseInt(num/3) + num%3); } }