#include <bits/stdc++.h> using namespace std; int main( ) { short n; int x=0,i=1; cin>>n; while(i<=n){ x+=i; i=i*i+i; } cout<<x: return 0; }