/*
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;
class Main extends JFrame{
ImageIcon body = new ImageIcon("new-moon.png");
ImageIcon eatenApple = new ImageIcon("eatenApple.png");
ImageIcon head = new ImageIcon("snake.png");
ImageIcon apple = new ImageIcon("apple.png");
JLabel [] snakeB = new JLabel[201];
JLabel appleE = new JLabel(eatenApple);
JLabel snakeH = new JLabel(head);
JLabel appleL = new JLabel(apple);
JLabel length = new JLabel("길이: 10");
Move move = new Move();
MoveB moveb = new MoveB();
int c1=0;
boolean flag= true;
Vector<Point> v = new Vector<Point>();
Container c = getContentPane();
public Main() {
setTitle("스네이크 움직이기");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.setLayout(null);
snakeH.setSize(32,32);
snakeH.setLocation(0,0);
c.add(snakeH);
appleL.setSize(32,32);
appleL.setLocation((int)(Math.random()*350),(int)(Math.random()*350));
c.add(appleL);
length.setSize(500,50);
length.setLocation(0,-15);
Font font = new Font("",Font.BOLD,20);
length.setFont(font);
c.add(length);
appleE.setSize(32,32);
appleE.setLocation(1000,1000);
c.add(appleE);
for(int i=0;i<200;i++) {
snakeB[i]= new JLabel(body);
snakeB[i].setSize(24,24);
snakeB[i].setLocation(1000,1000);
c.add(snakeB[i]);
}
c.addKeyListener(new MyKeyListener());
c.setFocusable(true);
c.requestFocus();
setSize(500,500);
setVisible(true);
}
int x=0, y=0, t=0;
int StartC=0;
class MyKeyListener extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int KeyCode = e.getKeyCode();
if(KeyCode==e.VK_RIGHT) {//1
if(StartC==0) {
t=1;
move.start();
moveb.start();
}
else t=1;
}
if(KeyCode==e.VK_LEFT) {//2
if(StartC==0) {
t=2;
move.start();
moveb.start();
}
else t=2;
}
if(KeyCode==e.VK_DOWN) {//3
if(StartC==0) {
t=3;
move.start();
moveb.start();
}
else t=3;
}
if(KeyCode==e.VK_UP) {//4
if(StartC==0) {
t=4;
move.start();
moveb.start();
}
else t=4;
}
repaint();
StartC++;
}
}
class Move extends Thread{
public void run(){
while(true) {
snakeH.setLocation(x,y);
if(appleL.getX()<snakeH.getX()+32&&appleL.getX()+32>snakeH.getX()&&appleL.getY()<snakeH.getY()+32&&appleL.getY()+32>snakeH.getY())
{
appleE.setLocation(appleL.getX(),appleL.getY());
apple();
}
if(t==1&&x+5<getWidth()-35) {
x+=5;
}
if(t==2&&x-5>-10) {
x-=5;
}
if(t==3&&y+5<getHeight()-50) {
y+=5;
}
if(t==4&&y-5>-10) {
y-=5;
}
try {
Thread.sleep(35);
}catch(InterruptedException e) {
return;
}
}
}
}
class MoveB extends Thread{
public void run() {
while(true){
v.add(snakeH.getLocation());
if(v.size()<10) {
for(int i=0;i<v.size();i++) {
snakeB[i].setLocation(v.get(i));
}
}
else {
for(int i=v.size()-10-c1;i<v.size();i++) {
snakeB[i-v.size()+10+c1].setLocation(v.get(i));
}
}
length.setText("길이: "+Integer.toString(10+c1));
try {
Thread.sleep(110);
} catch(InterruptedException e) {
return;
}
}
}
}
public void apple(){
c1++;
appleL.setLocation((int)(Math.random()*450),(int)(Math.random()*450));
}
public static void main(String[] args) {
new Main();
}
}
*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt(),k=sc.nextInt(),left=0,t=0,couponC=0,add;
while(couponC+(couponC+left)%k/k==0) {
left=n%k;
couponC=n/k;
n= (left+couponC)/k;
t+=n/k;
}
System.out.println(t);
}
}
*/