# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
#define out1(x)cout<<#x<<" is "<<x<<endl
#define out2(x,y)cout<<#x<<" is "<<x<<" "<<#y <<" is "<<y<<endl
#define out3(x,y,z)cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<" "<<#z<<" is "<<z<<endl;
#define out4(a,b,c,d)cout<<#a<<" is "<<a<<" "<<#b<<" is "<<b<<" "<<#c<<" is "<<c<<" "<<#d<<" is "<<d<<endl;
#define show(i,a,n) for(i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
#define exectime() cout<<"execution time "<<(double)(clock() - tStart)/CLOCKS_PER_SEC<<endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define F first
#define S second
#define PI 3.14159265359
#define FastIn std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define swap(VAR1,VAR2) VAR1=VAR1^VAR2;VAR2=VAR1^VAR2;VAR1=VAR1^VAR2
const ll MAXN = ll(5e6);
const ll INF = ll(1e17);
const ld EPS = ll(1e-9);
const ll MOD = ll(1e9) + 7;
const ll MILLION = ll(1e6);
const ll BILLION = ll(1e9);
const ll ONE = ll(1);
int main(){
FastIn;
clock_t tStart = clock();
string str,s,temp;
ll i,j,l;
cin>>str;
s = str;
j = 0;
l = s.size();
for(i=0;i<l;i++){
temp = string(str.begin() + i,str.end()) + string(str.begin(),str.begin() + i);
if(temp < s){
s = temp;
j = i;
}
}
printf("%lld",j);
//exectime();
return 0;
}
IyBpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgbG9uZyBkb3VibGUgbGQ7CnR5cGVkZWYgcGFpcjxsbCwgbGw+IHBsbDsKdHlwZWRlZiB2ZWN0b3I8bGw+IHZsbDsKdHlwZWRlZiBzZX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