1.

import java.util.Scanner;

/**
* Angewandte Mathematik, SS11
* Problem: 11877 - The Coco-Cola Store
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=2999
*
* @author Benedikt Zšnnchen
* @author Erik Wenzel
* @version 1.0, 03/27/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.120
*/

public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int emptyBottles;

while((emptyBottles = sc.nextInt()) != 0)
{
System.out.println(recBottleCalc(emptyBottles));
}
}

// loop
public static int bottleCalc(int emptyBottles)
{
int result = 0;
int tmp = 0;
while(emptyBottles!=0)
{
if(emptyBottles == 2)
{
result += 1;
emptyBottles = 0;
}
else if(emptyBottles > 2)
{
tmp = emptyBottles/3;
result += tmp;
emptyBottles = tmp + emptyBottles%3;
}
else
{
emptyBottles = 0;
}
}
return result;
}


// rekrusiv
public static int recBottleCalc(int emptyBottles)
{
if(emptyBottles >=3)
{
int tmp = emptyBottles/3;
return tmp + recBottleCalc(tmp+emptyBottles%3);
}
else if(emptyBottles == 2)
{
return 1;
}
else
{
return 0;
}
}
}


------------------------------------------------------------------------------------

1.
/*
* ACM Contest training
* Problem: 11877 - The Coco-Cola Store
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=226&page=show_problem&problem=2999
*
* @author Christoph Goettschkes
* @version 1.0, 11/08/2010
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.108
*/

import java.io.*;

class Main
{
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

int n = Integer.parseInt(reader.readLine().trim());

while (n > 0) {
int d = 0;

int full = 0;
int empty = n;
int counter = 7;
while (empty > 0 && counter > 0) {
full = empty / 3;
empty %= 3;
d += full;
empty += full;
full = 0;
counter--;
if (empty == 2)
empty++;
}
System.out.println(d);

n = Integer.parseInt(reader.readLine().trim());
}
}
}