/*
#include<stdio.h>
int map[100][100] = {0};
int queue[100000][2] = {0};
int front = 0, rear = 0;
void v()
{
int k = front;
int x, y, p;
int i;
for(i=rear; i<k; i++)
{
x = queue[i][0];
y = queue[i][1];
p = map[x][y];
if(map[x][y]==99)
{
}
if(map[x-1][y]==0)
{
map[x-1][y] = p+1;
queue[front][0] = x-1;
queue[front][1] = y;
front++;
}
if(map[x+1][y]==0)
{
map[x+1][y] = p+1;
queue[front][0] = x+1;
queue[front][1] = y;
front++;
}
if(map[x][y-1]==0)
{
map[x][y-1] = p+1;
queue[front][0] = x;
queue[front][1] = y-1;
front++;
}
if(map[x][y+1]==0)
{
map[x][y+1] = p+1;
queue[front][0] = x;
queue[front][1] = y+1;
front++;
}
rear++;
}
}
int main()
{
int x, y, i, j, n, k=0;
scanf("%d", &n);
for(i=0; i<=n+1; i++)
{
for(j=0; j<=n+1; j++)
{
if(i==0 || j==0 || i==n+1 || j==n+1)
{
map[i][j] = 9;
}
}
}
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j++)
{
scanf("%d", &map[i][j]);
if(map[i][j] > 0)
{
queue[front][0] = i;
queue[front][1] = j;
front++;
}
}
}
while(front != rear)
{
v();
}
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j++)
{
printf("%d ", map[i][j]);
}
printf("\n");
}
}
5
0 0 0 0 0
0 0 0 0 0
0 0 99 0 0
0 0 99 0 0
0 1 99 0 0
3,3
4,3
5,3
*/
/*
#include<stdio.h>
struct loc
{
int x,y;
};
char map[11][11]={0};
char result[11][11]={0};
struct loc location[100000]={0};
int front,rear;
int i,j;
void f1()
{
int x=location[front].x;
int y=location[front].y;
front++;
if(x==0||y==0||x==10||y==10) return;
int sum=0;
if(map[x][y]=='1')return;
for(i=-1;i<=1;i++)
{
for(j=-1;j<=1;j++)
{
if(map[x+i][y+j]=='1')
{
sum++;
}
}
}
if(sum>0)
{
result[x][y] = sum+'0';
return;
}
sum=0;
result[x][y]='X';
for(i=-1;i<=1;i++)
{
for(j=-1;j<=1;j++)
{
if(map[x+i][y+j]=='1')
{
sum++;
}
if(result[x+i][y+j]!='X'&&result[x+i][y+j]=='_'&&!sum)
{
location[rear].x = x+i;
location[rear].y = y+j;
rear++;
}
}
}
result[x][y] = (sum+'0');
}
int main()
{
front=rear=0;
int n,k,x,y;
for(i=1;i<=9;i++)
{
for(j=1;j<=9;j++)
{
scanf("%c",&map[i][j]);
result[i][j] = '_';
}
}
scanf("%d %d",&x,&y);
if(map[x][y]=='1')
{
for(i=1;i<=9;i++)
{
for(j=1;j<=9;j++)
{
if(x==i&&y==j)
{
printf("-1 ");
}
else
{
printf("_ ");
}
}
printf("\n");
}
return 0;
}
else
{
location[rear].x = x;
location[rear].y = y;
rear++;
for(;front!=rear;)
{
f1();
}
}
for(i=1;i<=9;i++)
{
for(j=1;j<=9;j++)
{
if(result[i][j]=='-1')
{
printf("-1");
}
else
{
printf("%c",result[i][j]);
}
}
printf("\n");
}
return 0;
}
*/
#include<stdio.h>
int a[10000]={0};
int k(int n,int c)
{
if(a[n]!=0) return a[n];
if(n<3) return n;
if(n==3) return k(n-1,0)+k(n-2,0)+n-2;
if(c>0)
return a[n] = (k(n-1,0)+k(n-2,0));
else
return a[n] = (k(n-1,0)+k(n-2,0)+k(n-3,2));
}
int main()
{
int n,c;
scanf("%d",&n);
printf("%d",k(n,c));
return 0;
}
/*
1=1
2=2
3=4
4=7
5=13
6=23
#include<stdio.h>
int memo[10001]={0};
int rec(int n)
{
if(memo[n]!=0) return memo[n];
if(n==1||n==2) return n;
else return rec(n-1)+rec(n-2);
}
int main()
{
int n;
scanf("%d",&n);
printf("%d",rec(n));
}
*/