# 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;
}