//斐波那契数列
import java.util.Scanner;
public class ssss
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.print(fib(n));
}
public static int fib(int n)
{
int f0, f1, f2;
f0 = f1 = 1;
f2 = 0;
if (n < 2)
return f1;
for (int i = 2; i <= n; i++)
{
f2 = f0 + f1;
f0 = f1;
f1 = f2;
}
return f2;
}
}
//矩阵连乘
import java.util.Scanner;
public class Hell2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m[][] = new int[n + 1][n + 1];
int s[][] = new int[n + 1][n + 1];
int p[] = new int[n + 1];
for (int i = 0; i <= n; i++)
{
p[i] = sc.nextInt();
}
matrixChain(p, n, m, s);
System.out.println(traceBack(1, n, s));
}
public static void matrixChain(int p[], int n, int m[][], int s[][]) {
for (int i = 1; i <= n; i++)//矩阵的个数为一的时候,乘的次数为0
{
m[i][i] = 0;//m[1][1]
}
for (int r = 2; r <= n; r++)//矩阵的个数为2个直到n个为止
{
for (int i = 1; i <= n - r + 1; i++)//矩阵从第一个开始
{
int j = i + r - 1;;//j=2
m[i][j] = m[i + 1][j] + p[i - 1] * p[i] * p[j];//m[1][2]=m[2][2]+p[0][1][2]
s[i][j] = i;//s[1][2]=1
for (int k = i; k < j; k++)
{
int t = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];//t=m[1][1]+m[2][2]+p[0][1][2]
if (t < m[i][j])
{
m[i][j] = t;
s[i][j] = k;
}
}
}
}
}
public static String traceBack(int i, int j, int s[][])
{
if (i == j)
{
return "A" + i;
}
else
{
return"(" + traceBack(i, s[i][j], s) + traceBack(s[i][j] + 1, j, s) + ")";
}
}
}
//背包问题
import java.util.Scanner;
public class Hell3
{
public static void main(String[] arg0)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();//物品个数
int c = sc.nextInt();//背包容量
int m[][] = new int[n + 1][c + 1];//最大价值
int v[] = new int[n + 1];//记录每个物品的价值
int w[] = new int[n + 1];//记录每个物品的重量
int x[] = new int[n + 1];//记录物品是否被放入背包
for (int i = 1; i <= n; i++)//存入每个物品的重量
{
w[i] = sc.nextInt();
}
for (int i = 1; i <= n; i++)//存入每个物品的价值
{
v[i] = sc.nextInt();
}
pa(c, n, v, w, m);
out(c,n,x,w, m);
for (int i = 1; i <= n; i++)
{
System.out.print(x[i] + " ");
}
}
// 背包问题的自底向上的算法
public static void pa(int c, int n, int v[], int w[], int m[][])
{
int jMax = Math.min(w[n] - 1, c);
for (int i = 0; i <= jMax; i++)
{
m[n][i] = 0;
}
for (int i = w[n]; i <= c; i++)
{
m[n][i] = v[n];
}
for (int i = n - 1; i >= 1; i--)
{
jMax = Math.min(w[i] - 1, c);
for (int j = 0; j <= jMax; j++)
{
m[i][j] = m[i + 1][j];
}
for (int j = w[i]; j <= c; j++)
{
m[i][j] = Math.max(m[i + 1][j], m[i + 1][j - w[i]] + v[i]);
}
}
}
//算法的最优解
public static void out(int c,int n,int x[], int w[], int m[][])
{
for (int i = 1; i < n; i++)
{
if (m[i][c] == m[i + 1][c])
{
x[i] = 0;
}
else
{
x[i] = 1;
c = c - w[i];
}
}
x[n] = (m[n][c] == 0 ? 0 : 1);
}
}
//二叉树
import java.util.Scanner;
public class Hell4
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int p[] = new int[n + 1];//成功的几率
int q[] = new int[n + 1];//失败的几率
int s[][] = new int[n + 2][n + 1];//最佳节点
int w[][] = new int[n + 2][n + 1];
int m[][] = new int[n + 2][n + 1];
for (int i = 1; i <= n; i++)
{
p[i] = sc.nextInt();
}
for (int i = 0; i <= n; i++)
{
q[i] = sc.nextInt();
}
bost(n, p, q, w, m, s);
T(1, n, s);//最优解
}
//出最优二叉搜索树的自底向上非递归的动态规划算法。
public static void bost(int n, int p[], int q[], int w[][], int m[][], int s[][])
{
for (int i = 0; i <= n; i++)
{
//5 15 10 5 10 20 5 10 5 5 5 10
w[i + 1][i] = q[i];
m[i + 1][i] = q[i];
}
for (int r = 0; r < n; r++)
{
for (int i = 1; i <= n - r; i++)
{
int j = i + r;//j=1
w[i][j] = w[i][j - 1] + p[j] + q[j];//w[1][1]=w[1][0]+p[1]+q[1]
m[i][j] = m[i][i - 1] + m[i + 1][j];//m[1][1]=m[1][0]+m[2][1]
s[i][j] = i;//s[1][1]=1
for (int k = i + 1; k <= j; k++)
{
int t = m[i][k - 1] + m[k + 1][j];//t=m[1][1]+m[3][1]
if (t < m[i][j])
{
m[i][j] = t;
s[i][j] = k;
}
}
m[i][j] += w[i][j];
}
}
}
public static void T(int i, int j, int s[][])//构造最优解
{
if (j > i)
{
int root = s[i][j];//根节点
System.out.println("s" + root + "是根");
if (s[i][root - 1] > 0)
{
System.out.println("s" + root + "的左孩子是s" + s[i][root - 1]);
}
if (s[root + 1][j] > 0)
{
System.out.println("s" + root + "的右孩子是s" + s[root + 1][j]);
}
T(i, root - 1, s);
T(root + 1, j, s);
}
}
}