最后一个样例过不去
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=105;
#define mod 998244353
int n,m;
bool c[N];
int cnt,ans;
void doit(int x){
while(x){
c[++cnt]=x%2;
x>>=1;
}
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
doit(m);
for(int i=1;i<=cnt;i++){
if(c[i]){
ans+=((n+1)/pow(2,i))*pow(2,i-1)+max(0ll,(n+1)%(int)pow(2,i)-(int)pow(2,i-1));
ans%=mod;
}
}
cout<<ans;
return 0;
}