#include<bits/stdc++.h>
#define int __int128
using namespace std;
int n,cnt=1,p;
int ans=1;
const int mod=998244353;
int qpow(int a,int b){
__int128 ans1=1;
while(b){
if(b&1){
ans1=(ans1*a)%mod;
}
a=(a*a)%mod;
b>>=1;
}
return ans1;
}
int read(){
int x=0,w=1;
char ch=0;
while(ch<'0'||ch>'9'){
if(ch=='-')w=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+(ch-'0');
ch=getchar();
}
return x*w;
}
void write(int x) {
if(x<0){
x=-x;
putchar('-');
}
if(x>9)write(x/10);
putchar(x%10+'0');
}
signed main(){
n=read();
n%=mod;
int x=1;
while(qpow(2,p)<n){
p++;
}
for(int i=1;i<=p;i++){
ans=(ans+((i+1)%mod*(qpow(2,i-1)%mod))%mod)%mod;
}
ans=(ans-((qpow(2,p)-n)%mod)*(p+1)%mod)%mod;
write(ans);
return 0;
}
最后一个子任务全WA