#include<bits/stdc++.h>
using namespace std;
struct TreapNode{
int value=-1,priority;
double wyc;
TreapNode* kids[2];
TreapNode*& left=kids[0];
TreapNode*& right=kids[1];
TreapNode(){
left=this;
right=this;
priority=-1;
wyc=-1;
}
TreapNode(int,double);
void pushup(double,double);
};
TreapNode* NIL=new TreapNode;
TreapNode::TreapNode(int v,double d){
left=NIL;
right=NIL;
priority=rand();
value=v;
wyc=d;
}
void TreapNode::pushup(double l,double r){
if(this==NIL){
return;
}
double mid=(l+r)/2;
wyc=mid;
left->pushup(l,mid);
right->pushup(mid,r);
}
string str;
constexpr double L=0;
constexpr double R=numeric_limits<unsigned long long>::max();
vector<TreapNode*> mapping;
bool awa(const int& i,const int& j){
return str[i]<str[j]||(str[i]==str[j]&&mapping[i+1]->wyc<mapping[j+1]->wyc);
}
struct Treap{
void insert(int value){
insert(root,value,L,R);
}
void inorder(){
inorder(root);
}
private:
void inorder(TreapNode*& n){
if(n==NIL){
return;
}
inorder(n->left);
cout<<n->value+1<<" ";
inorder(n->right);
}
TreapNode* root=NIL;
void rotate(TreapNode*& n,int direction,double l,double r){
TreapNode* nt=n->kids[direction];
n->kids[direction]=nt->kids[direction^1];
nt->kids[direction^1]=n;
n=nt;
n->pushup(l,r);
}
void insert(TreapNode*& n,int value,double l,double r){
if(n==NIL){
n=new TreapNode{value,(l+r)/2};
mapping[value]=n;
return;
}
int direction=awa(value,n->value)?0:1;
double mid=(l+r)/2;
insert(n->kids[direction],value,direction?mid:l,direction?r:mid);
if(n->priority<n->kids[direction]->priority){
rotate(n,direction,l,r);
}
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>str;
Treap t;
mapping.resize(str.size()+1,NIL);
for(int i=str.size()-1;i>=0;i-=1){
t.insert(i);
}
t.inorder();
}
RT