class Solution {
public int fib(int n) {
if(n<=1){
return n;
}
int first=0;
int second=1;
int res=0;
for(int i=2;i<=n;i++){
res=(first+second)%1000000007;
first=second%1000000007;
second=res%1000000007;
}
return res%1000000007;
}
}