import java.util.LinkedList;
import java.util.Scanner;
public class yueSeFuHuan {
public static void main(String[] args) {
int leftnum = 0;
int x = 0;
LinkedList list = new LinkedList();
Scanner console = new Scanner(System.in);
int num = console.nextInt();
for(int i = 1; i <= num; i++ ){
list.add(i);
}
System.out.println("建立的号码队列" + list);
while(list.size()>1){
for(int j = 0;j < list.size();j ++){
leftnum++;
if(leftnum == 3){
x = (int) list.get(j);
list.remove(j);
leftnum = 1;
if(j == list.size()||leftnum == 3){
leftnum = 0;
}
System.out.println("被去掉的号码" + x);
System.out.println("剩下的号码" + list);
}
}
}
System.out.println(list);
}
}