#include <iostream>
#include <cstring>
using namespace std;
int main() {
ifstream f("minlex.in");
ofstream g("minlex.out");
char s[200001];
f >> s;
char sir[200001];
int i = 0;
int h = strlen(s);
while (s[i] != '\0') {
sir[i] = s[i];
sir[h + i] = s[i];
++i;
}
int ii = 0;
for (int i = 0; i < h; ++i)
if (strcmp(sir + i, s) < 0) {
strcpy(s, sir + i);
ii = i;
}
g << ii;
return 0;
}