#include <iostream> #include <cstdio> using namespace std; int main() { int n,a,b; cin>>n; int res=n; while (n>=3){ a=n/3; res += a; b=n%3; n=a+b; } printf("%d",res); return 0; }