#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000000; ll dp[1000003][4]; int main(){ int n; cin>>n; memset(dp,0,sizeof(dp)); dp[1][1]=1; dp[2][2]=1; dp[3][1]=1; dp[3][2]=1; dp[3][3]=1; rep(i,4,n+1){ dp[i][1]=(dp[i-1][2]+dp[i-1][3])%mod; dp[i][2]=(dp[i-2][1]+dp[i-2][3])%mod; dp[i][3]=(dp[i-3][2]+dp[i-3][1])%mod; //print(1<<":"<