#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 5050

char s[NN];

VI pos[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	DO ans=0;

	for(int i=0; i<n; i++) pos[s[i]-'a'].pb(i);

	for(int i=0; i<26; i++) if(pos[i].size() && pos[i].size()<=26){

		DO mx=0;

		for(int j=0; j<n; j++){

			DO sum=0;

			int val[26]={0, };

			for(int k=0; k<pos[i].size(); k++){

				val[s[(pos[i][k]+j)%n]-'a']++;

			}

			for(int k=0; k<26; k++){

				if(val[k]==1) sum+=1.0/n;

			}

			smax(mx, sum);

		}

		ans+=mx;

	}

	printf("%.12lf\n", ans);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-9

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define sgn(x) (((x)>eps)-((x)<-eps))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y) {printsp(x); println(y);}

template<class T, class U, class V>inline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 101010

char s[NN];

VI a[26];

int flag, vst[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for (int i=0; i<n; i++) a[s[i]-'a'].pb(i);

	for (int i=0; i<n; i++) s[i+n]=s[i];

	double ans, m=0;

	for (int i=0; i<26; i++) if (a[i].size()) {

		int cnt=0; DO mid=0;

		for (int r=0; r<n; r++) {

			for (int j=0; j<26; j++) vst[j]=0;

			for (int j=0; j<a[i].size(); j++) vst[s[a[i][j]+r]-'a']++;

			int ok=0;

			for (int j=0; j<26; j++) if (vst[j]==1) ok++;

			mid+=(DO)ok/a[i].size();

			if (ok) cnt++;

		}

		if (cnt) ans+=mid/cnt*a[i].size()/n;

	}

	printf("%.10lf\n", ans);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 5050

char s[NN];

VI pos[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	DO ans=0;

	for(int i=0; i<n; i++) pos[s[i]-'a'].pb(i);

	for(int i=0; i<26; i++) if(pos[i].size()){

		DO mx=0;

		for(int j=0; j<n; j++){

			DO sum=0;

			int val[26]={0, };

			for(int k=0; k<pos[i].size(); k++){

				val[s[(pos[i][k]+j)%n]-'a']++;

			}

			for(int k=0; k<26; k++){

				if(val[k]==1) sum+=1.0/n;

			}

			smax(mx, sum);

		}

		ans+=mx;

	}

	printf("%.12lf\n", ans);

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-9

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(_) ((_)*(_))

#define cb(_) ((_)*(_)*(_))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bclzl(x) (__builtin_clzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template<class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1), gn(x2), gn(x3);}

template<class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1), gn(x2), gn(x3), gn(x4);}

template<class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T> inline void printsp(T x) {print(x); putchar(' ');}

template<class T> inline void println(T x) {print(x); putchar('\n');}

template<class T1, class T2> inline void print(T1 x1, T2 x2){printsp(x1), println(x2);}

template<class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3){printsp(x1), printsp(x2), println(x3);}

template<class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4){printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 10010

#define MM 30

char s[NN];

int flag[MM];

VI pos[MM];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for(int i=0; i<n; i++) {

		pos[s[i]-'a'].pb(i);

		s[n+i]=s[i];

	}

	int ans;

	for(int i=0; i<26; i++) {

		int mx=0;

		for(int j=1; j<n; j++) {

			memset(flag, 0, sizeof flag);

			for(auto x: pos[i]) {

				flag[s[x+j]-'a']++;

			}

			int cnt=0;

			for(int k=0; k<26; k++) if(flag[k]==1) {

				cnt++;

			}

			smax(mx, cnt);

		}

		ans+=mx;

	}

	printf("%.7lf\n", 1.*ans/n);

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-9

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define sgn(x) (((x)>eps)-((x)<-eps))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef long double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T>inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<class T>inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T>inline void printsp(T x) {print(x); putchar(' ');}

template<class T>inline void println(T x) {print(x); putchar('\n');}

template<class T, class U>inline void print(T x, U y) {printsp(x); println(y);}

template<class T, class U, class V>inline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 101010

char s[NN];

VI a[26];

int flag, vst[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for (int i=0; i<n; i++) a[s[i]-'a'].pb(i);

	for (int i=0; i<n; i++) s[i+n]=s[i];

	int ans=0;

	for (int i=0; i<26; i++) if (a[i].size()) {

		int c=0;

		for (int r=0; r<n; r++) {

			for (int j=0; j<26; j++) vst[j]=0;

			for (int j=0; j<a[i].size(); j++) vst[s[a[i][j]+r]-'a']++;

			int ok=0;

			for (int j=0; j<26; j++) if (vst[j]==1) ok++;

			smax(c, ok);

		}

		ans+=c;

	}

	printf("%.15lf\n", (double)ans/n);

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-9

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(_) ((_)*(_))

#define cb(_) ((_)*(_)*(_))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bclzl(x) (__builtin_clzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template<class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1), gn(x2), gn(x3);}

template<class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1), gn(x2), gn(x3), gn(x4);}

template<class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T> inline void printsp(T x) {print(x); putchar(' ');}

template<class T> inline void println(T x) {print(x); putchar('\n');}

template<class T1, class T2> inline void print(T1 x1, T2 x2){printsp(x1), println(x2);}

template<class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3){printsp(x1), printsp(x2), println(x3);}

template<class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4){printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 10010

#define MM 30

char s[NN];

int flag[MM];

VI pos[MM];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for(int i=0; i<n; i++) {

		pos[s[i]-'a'].pb(i);

		s[n+i]=s[i];

	}

	int ans;

	for(int i=0; i<26; i++) {

		int mx=0;

		for(int j=1; j<n; j++) {

			for(auto x: pos[i]) {

				flag[s[x+j]-'a']++;

			}

			int cnt=0;

			for(int k=0; k<26; k++) if(flag[k]==1) {

				cnt++;

			}

			smax(mx, cnt);

		}

		ans+=mx;

	}

	printf("%.7lf\n", 1.*ans/n);

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 5050

char s[NN];

VI pos[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	int ans=0;

	for(int i=0; i<n; i++) pos[s[i]-'a'].pb(i);

	for(int i=0; i<26; i++) if(pos[i].size() && pos[i].size()<=26){

		for(int j=0; j<n; j++){

			int val=0;

			for(int k=0; k<pos[i].size(); k++){

				val^=1<<(s[(pos[i][k]+j)%n]-'a');

			}

			if(bpt(val)==pos[i].size()){

				ans+=pos[i].size();

				break;

			}

		}

	}

	printf("%.12lf\n", (DO)ans/n);

	return 0;

}


#include <bits/stdc++.h>

#define inf 0x3f3f3f3f

#define INF 0x3f3f3f3f3f3f3f3fLL

#define MOD 1000000007

#define pb push_back

#define sq(x) ((x)*(x))

#define x first

#define y second

#define eps 1e-8

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define bit(x, y) (((x)>>(y))&1)

#define bclz(x) (__builtin_clz(x))

#define bclzl(x) (__builtin_clzll(x))

#define bctz(x) (__builtin_ctz(x))

#define bctzl(x) (__builtin_ctzll(x))

using namespace std;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

typedef double DO;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<typename T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T, class T1>inline void gn(T &x, T1 &y) {gn(x); gn(y);}

template<class T, class T1, class T2>inline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}

template<typename T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<typename T> inline void println(T x) {print(x), putchar('\n');}

template<typename T> inline void printsp(T x) {print(x), putchar(' ');}

template<class T, class T1> inline void print(T x, T1 y) {printsp(x), println(y);}

template<class T, class T1, class T2> inline void print(T x, T1 y, T2 z) {printsp(x), printsp(y), println(z);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#define NN 5050

char s[NN];

VI pos[26];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	int ans=0;

	for(int i=0; i<n; i++) pos[s[i]-'a'].pb(i);

	for(int i=0; i<26; i++) if(pos[i].size() && pos[i].size()<=26){

		for(int j=0; j<n; j++){

			int val=0;

			for(int k=0; k<pos[i].size(); k++){

				val^=1<<(s[(pos[i][k]+j)%n]-'a');

			}

			if(bpt(val)==pos[i].size()){

				ans+=pos[i].size();

				break;

			}

		}

	}

	smax(ans, 1);

	printf("%.12lf\n", (DO)ans/n);

	return 0;

}


#include <bits/stdc++.h>

#define x first

#define y second

#define eps 1e-9

#define pb push_back

#define inf 0x3f3f3f3f

#define mod 1000000007

#define sq(_) ((_)*(_))

#define cb(_) ((_)*(_)*(_))

#define bit(x, y) (((x)>>(y))&1)

#define bctz(x) (__builtin_ctz(x))

#define bclz(x) (__builtin_clz(x))

#define bctzl(x) (__builtin_ctzll(x))

#define bclzl(x) (__builtin_clzll(x))

#define bpt(x) (__builtin_popcount(x))

#define bptl(x) (__builtin_popcountll(x))

#define PQ priority_queue<pii, vector<pii>, greater<pii> >

using namespace std;

typedef double DO;

typedef long long INT;

typedef vector<int> VI;

typedef pair<int, int> pii;

typedef pair<pii, int> pi3;

template<typename T, typename U> inline void smin(T &a, U b) {if (a>b) a=b;}

template<typename T, typename U> inline void smax(T &a, U b) {if (a<b) a=b;}

template<class T> inline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if (sg) x=-x;}

template<class T1, class T2> inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}

template<class T1, class T2, class T3> inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1), gn(x2), gn(x3);}

template<class T1, class T2, class T3, class T4> inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1), gn(x2), gn(x3), gn(x4);}

template<class T> inline void print(T x) {if (x<0) {putchar('-');return print(-x);}if (x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}

template<class T> inline void printsp(T x) {print(x); putchar(' ');}

template<class T> inline void println(T x) {print(x); putchar('\n');}

template<class T1, class T2> inline void print(T1 x1, T2 x2){printsp(x1), println(x2);}

template<class T1, class T2, class T3> inline void print(T1 x1, T2 x2, T3 x3){printsp(x1), printsp(x2), println(x3);}

template<class T1, class T2, class T3, class T4> inline void print(T1 x1, T2 x2, T3 x3, T4 x4){printsp(x1), printsp(x2), printsp(x3), println(x4);}

int power(int a, int b, int m, int ans=1) {

	for (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;

	return ans;

}

#ifndef ONLINE_JUDGE

void debug() {cout << endl;}

template<typename T, typename... Args>void debug(T&& head, Args&&... tail) {cout << head << ' ';debug(tail...);}

#endif

#define NN 5010

char s[NN<<1];

string ss[NN];

int main() {

#ifndef ONLINE_JUDGE

	freopen("in.in", "r", stdin);

	freopen("out.out", "w", stdout);

#endif

	scanf("%s", s);

	int n=strlen(s);

	for(int i=0; i<n; i++) s[n+i]=s[i];

	int num=0;

	for(int k=0; k<n; k++) {

		for(int i=0; i<n; i++) {

			ss[i].clear();

			ss[i].pb(s[i]);

			ss[i].pb(s[i+k]);

		}

		int cnt=0;

		sort(ss, ss+n);

		for(int i=0, j=0; i<n; i=j) {

			for(j=i; j<n; j++) if(ss[i]!=ss[j]) {

				break;

			}

			if(j==i+1) cnt++;

		}

		smax(num, cnt);

	}

	printf("%.7lf\n", 1.*num/n);

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>
#include<cassert>
#include<iomanip>
#include<limits>

using namespace std;

#define double long double

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
typedef pair<int,ii> iii2;
typedef pair<ii,ii> iiii;
typedef vector<int> vi;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;

string s;
vector<int> a;
int l;
int main(){
	cin>>s;
	l = (int)s.length();
	a.assign(l,0);
	for(int i=0;i<l;i++) a[i] = (int)(s[i]-'a');
	vector<vector<vector<int> > > p(26,vector<vector<int> >(l,vector<int>(26,0)));

	for(int i=0;i<l;i++){
		for(int j=1;j<l;j++){
			p[a[i]][j][a[(i+j)%l]]++;
		}
	}

	double ans = 0;

	vector<bool> flag(26,false);
	for(int i=0;i<26;i++){
		for(int j=1;j<l;j++){
			bool can = true;
			for(int k=0;k<26;k++){
				if(p[i][j][k]>1) can = false;
			}
			if(can){
				flag[i] = true;
				break;
			}
		}
	}

	for(int i=0;i<l;i++) if(flag[a[i]]) ans+=1.0;
	cout<<setprecision(10)<<fixed<<ans/l<<endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<bitset>
#include<set>
#include<cstdlib>
#include<complex>
#include<list>
#include<sstream>
#include<cassert>
#include<iomanip>
#include<limits>

using namespace std;

#define double long double

typedef pair<int,int> ii;
typedef pair<int,long long> il;
typedef pair<long long,long long> ll;
typedef pair<ll,int> lli;
typedef pair<long long,int> li;
typedef pair<double,double> dd;
typedef pair<ii,int> iii;
typedef pair<double,int> di;
typedef pair<int,ii> iii2;
typedef pair<ii,ii> iiii;
typedef vector<int> vi;
long long mod = 1000000007LL;
long long large = 2000000000000000000LL;

string s;
vector<int> a;
int l;
int main(){
	cin>>s;
	l = (int)s.length();
	a.assign(l,0);
	for(int i=0;i<l;i++) a[i] = (int)(s[i]-'a');
	vector<vector<vector<int> > > p(26,vector<vector<int> >(l,vector<int>(26,0)));

	for(int i=0;i<l;i++){
		for(int j=1;j<l;j++){
			p[a[i]][j][a[(i+j)%l]]++;
		}
	}

	double ans = 0;

	vector<double> flag(26,0);
	for(int i=0;i<26;i++){
		for(int j=1;j<l;j++){
			int cnt = 0;
			int tot = 0;
			for(int k=0;k<26;k++){
				if(p[i][j][k]==1) cnt++;
				tot+=p[i][j][k];
			}
			flag[i] = max(flag[i],(double)cnt/tot);
		}
	}

	for(int i=0;i<l;i++) ans+=flag[a[i]];
	cout<<setprecision(10)<<fixed<<ans/l<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
string st;
int ansn,sum;
int f[10010][30],a[10010],nu,tt;
int main(){
	cin>>st;
	int l=st.length();
	for (int i=1;i<=l;i++) a[i]=st[i-1]-'a';
	for (int i=l+1;i<=l*2;i++) a[i]=a[i-l];
	for (int j=0;j<26;j++){
		nu=0;
		memset(f,0,sizeof(f));
		for (int k=1;k<=l;k++){
			if (a[k]==j){for (int i=k;i<k+l;i++) f[i-k][a[i]]++;nu++;}
		}
		sum=l;
		for (int i=1;i<l;i++){
			tt=0;
			for (int j=0;j<26;j++){
				if (f[i][j]>=2) tt+=f[i][j];
			}
			sum=min(sum,tt);
		}
		ansn+=sum;
	}
	printf("%.9lf\n",(double)(l-ansn)/(l));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, cnt[256], hv, best, ans;
char x[5005];
vector< string > s[256];

int main() {
	scanf("%s", x);
	n = strlen(x);
	for (int i = 0; i < n; i++)
		s[x[i]].push_back(string(x + i) + string(x, i));
	for (int i = 'a'; i <= 'z'; i++) {
		best = 0;
		for (int j = 1; j < n; j++) {
			for (int k = 0; k < s[i].size(); k++)
				cnt[s[i][k][j]]++;
			hv = 0;
			for (int k = 'a'; k <= 'z'; k++) {
				hv += cnt[k] == 1;
				cnt[k] = 0;
			}
			best = max(best, hv);
		}
		ans += best;
	}
	printf("%.10lf\n", (double)ans / n);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long double ld;

const int Maxl = 26;

string s;
vector <int> my[Maxl];
int has[Maxl];
ld res;

int main()
{
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		my[s[i] - 'a'].push_back(i);
	for (int i = 0; i < Maxl; i++) if (!my[i].empty()) {
		int mx = 0;
		for (int j = 1; j < s.length(); j++) {
			int mask = 0;
			for (int l = 0; l < my[i].size(); l++) {
				int ind = my[i][l];
				int oth = (ind + j) % int(s.length());
				has[s[oth] - 'a'] = 0;
				mask |= 1 << int(s[oth] - 'a');
			}
			for (int l = 0; l < my[i].size(); l++) {
				int ind = my[i][l];
				int oth = (ind + j) % int(s.length());
				has[s[oth] - 'a']++;
			}
			int res = 0;
			while (mask) {
				int b = __builtin_popcount((mask & -mask) - 1);
				res += has[b] == 1;
				mask ^= 1 << b;
			}
			mx = max(mx, res);
		}
		res += mx / ld(s.length());
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long double ld;

const int Maxl = 26;

string s;
int has[Maxl][Maxl];
ld res;

int main()
{
	cin >> s;
	for (int i = 1; i < s.length(); i++) {
		fill((int*)has, (int*)has + Maxl * Maxl, 0);
		for (int j = 0; j < s.length(); j++) {
			int oth = (j + i) % int(s.length());
			has[s[j] - 'a'][s[oth] - 'a']++;
		}
		int tot = 0;
		for (int a = 0; a < Maxl; a++)
			for (int b = 0; b < Maxl; b++) if (has[a][b] == 1)
				tot++;
		res = max(res, ld(tot) / ld(s.length()));
	}
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#define oo 2139062143
#define fo(i,x,y) for (int i=(x);i<=(y);++i)
using namespace std;
const int N=10010;
int len,n,ans;
char s[N];
int nex[N],las[27];
int d[N],d0;
int bz[27];
int main()
{
//	freopen("D:/LiuYuanHao/a.in","r",stdin);
	scanf("%s",s+1);len=strlen(s+1);
	fo(i,1,len)
	{
		s[len+i]=s[i];
		nex[i]=las[s[i]-'a'];
		las[s[i]-'a']=i;
	}n=len*2;
	fo(i,0,25)
	{
		d0=0;
		for(int j=las[i];j;j=nex[j]) d[++d0]=j;
		int mx=0,cnt;
		fo(a,0,len-1)
		{
			cnt=0;
			memset(bz,0,sizeof bz);
			int flag=1;
			fo(j,1,d0) ++bz[s[d[j]+a]-'a'];
			fo(i,0,25)if(bz[i]==1) ++cnt;
			mx=max(mx,cnt);
		}
		ans+=mx;
	}
	printf("%.9lf",(double)ans/len);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 5001
#include<cstring>
using namespace std;
int bz[26][26][5001];
int n;
char s[N];
int main(){
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++)s[i]-='a';
	for (int i=0;i<n;i++){
		int x=(i+1)%n;
		int y=1;
		while (x!=i)
			bz[s[i]][s[x]][y]++,x=(x+1)%n,y++;
	}
	int ans=0;
	for (int i=0;i<26;i++){
		int s=0;
		for (int j=1;j<=n;j++){
			int s1=0;
			for (int k=0;k<26;k++)	s1+=(bz[i][k][j]==1);
			s=max(s,s1);
		}
		ans+=s;
	}
	printf("%.9lf",(double)ans/n);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int g[30][5002][30];
int cnt[33];
int main() {
    string s;
    cin >> s;
    int n = s.size();
    double ans = 0;
    memset(cnt, 0, sizeof(cnt));
    memset(g, 0, sizeof(g));
    for (int i = 0; i < n; i++) {
        cnt[s[i] - 'a']++;
        for (int j = 1; j < n; j++) {
            g[s[i] - 'a'][j][s[(i + j) % n] - 'a']++;
        }
    }
    double ma, cur;
    for (int i = 0; i < 26; i++) {
        ma = 0;
        for (int j = 1; j < n; j++) {
            cur = 0;
            for (int k = 0; k <= 25; k++) {
                if (g[i][j][k] == 1){
                    cur += 1.0 / (double)n;
                }
            }
            ma = max(ma, cur);
        }
        ans += ma;
    }
    printf("%.9lf\n", ans);
}


#include <stdio.h>
#include <string>
#include <string.h>
using namespace std;

const int MAX_LEN = 5005;
const int INF = (int)1e9;

char a[MAX_LEN];
int freq[MAX_LEN][26][26];
int counter[26];

int main(void) {
    int n;
    string s;

    scanf(" %s", a);
    n = strlen(a);
    s = string(a) + string(a);
    for (int i = 0; i < n; i++) {
        int start = s[i] - 'a';
        counter[start]++;
        for (int j = 1; j < n; j++) {
            int idx = s[i + j] - 'a';
            freq[j][start][idx]++;
        }
    }

    double ans = 0;
    for (int let = 0; let < 26; let++) {
        if (counter[let] == 0) {
            continue;
        }
        int best_mini = INF;
        int best_qt = 0;
        for (int dis = 1; dis < n; dis++) {
            int mini = INF;
            int qt = 0;
            for (int j = 0; j < 26; j++) {
                if (freq[dis][let][j] != 0) {
                    if (freq[dis][let][j] < mini) {
                        qt = 1;
                        mini = freq[dis][let][j];
                    } else if (freq[dis][let][j] == mini) {
                        qt++;
                    }
                }
            }
            if (mini < best_mini) {
                best_mini = mini;
                best_qt = qt;
            } else if (mini == best_mini) {
                best_qt = max(best_qt, qt);
            }
        }
        //printf("let = %d, mini = %d, qt = %d\n", let, best_mini, best_qt);
        if (best_mini == 1) {
            ans += (1.0 / n) * ((counter[let] * (best_qt)) / (1.0 * counter[let]));
        }
    }
    printf("%.12f\n", ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>vs[26];
char s[5005];
int n,cnt[26];
int main(){
	scanf("%s",s);
	n=strlen(s);
	for(int i=0;i<n;++i){
		vs[s[i]-'a'].push_back(i);
	}
	int ans=0;
	for(int i=0;i<26;++i){
		int maxx=0;
		for(int j=1;j<n;++j){
			memset(cnt,0,sizeof(cnt));
			for(int k=0;k<vs[i].size();++k){
				++cnt[s[(vs[i][k]+j)%n]-'a'];
			}
			int sum=0;
			for(int k=0;k<26;++k){
				if(cnt[k]==1){
					++sum;
				}
			}
			maxx=max(maxx,sum);
		}
		ans+=maxx;
	}
	printf("%.15lf\n",(double)ans/(double)n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 5000;

int n;
char s[N + 1];
int maxn;
int res;

struct P {
	int len;
	char s[N + 1];

	friend bool operator< (P a, P b) {
		for(int i = 1; i <= a.len; i++)
			if(a.s[i] != b.s[i])
				return a.s[i] < b.s[i];
		return 0;
	}
}T[N + 1];

int vis[26];

bool pd(char ch) {
	if(ch >= 'a' && ch <= 'z') return 1;
	return 0;
}

void work(int l, int r) {
	maxn = 0;
	for(int i = 2; i <= n; i++) {
		int tot = 0;
		for(int j = l; j <= r; j++) {
			if(pd(T[j].s[i]) && !vis[T[j].s[i] - 'a']) tot++;
			if(pd(T[j].s[i]) && vis[T[j].s[i] - 'a'] == 1) tot--;
			vis[T[j].s[i] - 'a']++;
		}
		maxn = max(maxn, tot);
		memset(vis, 0, sizeof(vis));
	}
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		T[i].len = n;
		for(int j = 1; j <= n; j++) {
			T[i].s[j] = s[(i + j - 2) % n + 1];
		}
	}
	sort(T + 1, T + 1 + n);
	int la = 1;
	for(int i = 2; i <= n + 1; i++) {
		if(T[i].s[1] != T[la].s[1]) {
			work(la, i - 1);
			res += maxn;
			la = i;
		}
	}
	printf("%.6lf\n", res * 1.000000 / n);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

const int MAXN = 5005;

int N;

char s[MAXN];

int chk[26][26][MAXN];

int main(){
	scanf("%s", s); N = strlen(s);
	up (i, 0, N - 1) up (j, 0, N - 1) chk[s[i] - 'a'][s[(i + j) % N] - 'a'][j]++;
	db ans = 0;
	up (i, 0, 25) {
		db cur = 0;
		up (j, 0, N - 1) {
			int sum = 0;
			up (k, 0, 25) if (chk[i][k][j] == 1) sum++;
			cmax(cur, (db)sum / N);
		}
		ans += cur;
	}
	printf("%.10lf\n", ans);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
typedef double db;
char s[5010];
int n;
int L[5010];
int sum[200];
int ans;
int main() {
//	freopen("b.in","r",stdin);
	scanf("%s",s); n=strlen(s);
	for (char c='a'; c<='z'; c++) {
		L[0]=0;
		for (int i=0; i<n; i++) if (s[i]==c) L[++L[0]]=i;
		if (L[0]==0) continue;
		int mx=0;
		for (int i=1; i<n; i++) {
			memset(sum,0,sizeof sum);
			for  (int j=1; j<=L[0]; j++) sum[s[(i+L[j])%n]]++;
			int cnt=0; for  (char j='a'; j<='z'; j++) if (sum[j]==1) cnt++;
			mx = max(mx,cnt);
		}
		ans+=mx;
	}
	printf("%.9lf",ans / (db) n);
}


#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
//#define mod 987654321
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 5005

string s;
bool can[maxn];
int num[maxn], f[maxn], d[maxn];

int main() {

//	freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(0);

	cin >> s;
	int n = sz(s);
	ms(can, 0);
	ms(f, 0);
	for(int add = 1; add < n; add++){
		ms(num, 0);
		ms(d, 0);
		for(int i = 0; i < n; i++){
			int j = i + add;
			if(j >= n) j -= n;
			int x = (s[i] - 'a') * 35 + s[j] - 'a';
			num[x]++;
		}
		for(int i = 0; i < n; i++){
			int j = i + add;
			if(j >= n) j -= n;
			int x = (s[i] - 'a') * 35 + s[j] - 'a';
			if(num[x] == 1) {
				can[i] = 1;
				d[s[i] - 'a']++;
			}
		}
		Rep(i, 40) f[i] = max(f[i], d[i]);
	}

	int res = 0;
	Rep(i, 40) {
		res += f[i];
//		if(can[i]) cout << i << endl;
	}

	cout << fixed << setprecision(10) << res * (ld)(1.0) / n << endl;

	cin.tie(0);

	return 0;
}


/*input
aaaaab

*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long int pow(long long int a, long long int b, long long int mod){
	if(b==1)return a;
	if(b==0)return 1;
	long long int ret = pow(a, b/2 ,mod);
	ret = ret * ret;
	ret %= mod;
	if(b&1){
		ret=ret*a;
		ret %= mod;
	}
	return ret;
}

int cnt[26]={0}, n;
int main() {
	long double p,q,r=0;
	string s;
	cin>>s;
	n = s.length();
	for(int i=0;i<n;i++){
		cnt[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(cnt[i]==0)continue;
		//cout<<cnt[i]<<endl;
		int fl = 0, pp=0, pq=0;
		for(int p=0;p<n;p++){
			int pk[26]={0};
			pp = 0;
			for(int j=0;j<s.length();j++){
				if(s[j]-'a'==i){
					pk[s[(j+p)%n]-'a']++;
				}
			}
			for(int ii=0;ii<26;ii++)if(pk[ii]==1)pp++;
			pq = max(pp, pq);
		}

		r += pq;
	}
	q = n;
	r/=n;
	printf("%.15f\n", double(r));

}


#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 100 * 1000 + 47;

char S[MAX];
VI V[MAX];
int X[MAX][33];

int main()
{
    //freopen("in.txt", "r", stdin);
    //ios::sync_with_stdio(false); cin.tie(0);
    scanf("%s", S);
    int n = strlen(S);
    FOR(i, 0, n)
        V[S[i]-'a'].PB(i);
    double ans = 0;
    FOR(i, 0, 26)
    {
        FOR(i, 0, n)FOR(j, 0, 26)X[i][j] = 0;
        if (SZ(V[i]) == 0)continue;
        FOR(j, 0, SZ(V[i]))
        {
            int idx = V[i][j];
            FOR(d, 1, n)
            {
                int pp = idx + d;
                while(pp >= n)pp -= n;
                X[d][S[pp] - 'a']++;
            }
        }

        //bool fnd = 0;
        double p = 0;
        FOR(j, 1, n)
        {
            int tot = 0;
            FOR(k, 0, 26)
                //if (X[j][k])
                    tot+=X[j][k];
            int cnt = 0;
            FOR(k, 0, 26)
                if (X[j][k] == 1)
                    cnt++;
            double sol = cnt / (double) tot;
            p = max(p, sol);
        }
            ans += p * SZ(V[i]) / (double) n;
    }
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}


#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack>

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;
typedef struct { ll x; ll y; } Point;

using namespace std;

string str;
vector <int> pos[26];
double ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> str;
	str = str;
	ans = 0;
	int n = str.length();
	for (int i = 0; i < n; i++) pos[str[i] - 'a'].push_back(i);
	for (int i = 0; i < 26; i++) {
		if (pos[i].size() == 1) {
			ans += 1.0 / n;
			continue;
		}
		if (pos[i].size() == 0) continue;
		int maxi = -INF;
		for (int k = 0; k < n; k++) {
			int used[26];
			for (int x = 0; x < 26; x++) used[x] = 0;
			for (int j = 0; j < pos[i].size(); j++) {
				int index = pos[i][j] + k >= n ? pos[i][j] + k - n : pos[i][j] + k;
				used[str[index] - 'a']++;
			}
			int cc = 0;
			for (int j = 0; j < 26; j++) {
				if (used[j] == 1) cc++;
			}
			maxi = max(cc, maxi);
		}
		ans += 1.0 / n * maxi;
	}
	printf("%.9lf\n", ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
using namespace std;
int a[5010][30][30];
int b[30];
int main()
{
    string s;
    cin>>s;
    for (int i=0;i<s.length();i++) b[s[i]-'a']++;
    for (int len=1;len<=s.length();len++)
    {
        for (int i=0;i<s.length();i++)
        {
            int j=(i+len-1)%s.length();
            a[len][s[i]-'a'][s[j]-'a']++;
        }
    }
    double ans=0;
    for (int i=0;i<26;i++)
    {
        if (b[i]==0) continue;
        int m=0;
        for (int len=1;len<=s.length();len++)
        {
            int j,k=0;
            for (j=0;j<26;j++) if (a[len][i][j]==1) k++;
            m=max(m,k);
        }
        ans+=m;
    }
    ans/=s.length();
    cout.precision(10);
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 30;

vector<string> A[MAX];

int CNT[MAX];
int U[MAX];
int iter = 0;

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	string s;
	cin>>s;

	FOR (it, 0, SZ(s))
	{
		A[s[0] - 'a'].PB(s);
		s.PB(s[0]);
		s.erase(s.begin());
	}

	double res = 0;

	FOR (i, 0, MAX)
	{
		vector<string>& a = A[i];
		if (a.empty()) continue;

		int mx = 0;

		FOR (j, 0, SZ(a[0]))
		{
			iter++;
			int cnt = 0;
			FOR (k, 0, SZ(a))
			{
				int cur = a[k][j] - 'a';
				if (U[cur] != iter)
				{
					U[cur] = iter;
					CNT[cur] = 0;
				}

				CNT[cur]++;
				if (CNT[cur] == 1) cnt++;
				if (CNT[cur] == 2) cnt--;
			}

			mx = max(mx, cnt);
		}

		double prob = mx / (double)SZ(s);
		res += prob;
	}

	printf("%.11f\n", res);

}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int static const N = 200010;

char c[N];
int a[40][N], n, ima[3132], broj[40];

int main()
{
	scanf("%s",&c);
	n = strlen(c);
	for(int i=0;i<n;i++)
		ima[c[i]]++;
	double pmax = 0;
	for(int i='a';i<='z';i++)
	{
		double p = 0;
		if(ima[i] != 0)
		{
			for(int j=0;j<n;j++)
			{
				for(int j1=0;j1<'z'-'a'+1;j1++)
					broj[j1] = 0;
				int t = 0;
				for(int k=0;k<n;k++)
				{
					if(c[k] == i)
						broj[c[(k+j)%n]-'a']++;
				}
				for(int j1=0;j1<'z'-'a'+1;j1++)
					if(broj[j1] == 1)
						t++;
				if(t > p)
					p = t;
			}
		}
		p /= n;
		pmax += p;
	}

	printf("%.10lf\n",pmax);

	return 0;
}


#include<cstring>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<iostream>
#include<iomanip>
#define fo(i,a,b)for(int i=a,E=b;i<=E;i++)
#define fd(i,a,b)for(int i=b,E=a;i>=E;i--)
#define max(a,b)(a>b?a:b)
#define min(a,b)(a<b?a:b)
#define ll long long
#define db double
const int N=10005,mo=998244353;
int n,a[N],la[30],ne[N],w[N],r,g[30],gs,ma,an,ans;
char cc[N],ch;
int main(){
//	freopen("a.in","r",stdin);
	for(;(ch=getchar())<='z'&&ch>='a';)cc[++n]=ch-'a',ne[n]=la[cc[n]],la[cc[n]]=n;
	fo(i,n+1,n+n)cc[i]=cc[i-n];
	fo(i,0,25){
		ma=r=0;
		for(int j=la[i];j;j=ne[j])w[++r]=j;
		fo(k,1,n-1){
			memset(g,0,sizeof g);gs=0;
			fo(j,1,r)g[cc[w[j]+k]]++;
			fo(j,0,25)if(g[j]==1)gs++;
			ma=max(gs,ma);
		}
		an+=ma;
	}
	printf("%.10lf",(db)an/n);
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cctype>
using namespace std;
typedef long long ll;
inline ll read() {
	char ch = getchar(); ll x = 0; int op = 1;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') op = -1;
	for(; isdigit(ch); ch = getchar()) x = x*10+ch-'0';
	return x*op;
}
inline void write(ll a) {
	if(a < 0) putchar('-'), a = -a;
	if(a >= 10) write(a/10); putchar('0'+a%10);
}
const int N = 10010;
const int mod = 23333333;
const int base = 3;
char s[N];
int n, a[N], b[30], fl[30], f[30][N][30];
int main() {
	scanf("%s", s+1); n = strlen(s+1);
	for(int i = 1; i <= n; i ++) {
		a[i+n] = a[i] = s[i]-'a';
		b[a[i]] ++;
	}
	for(int i = 1; i <= n; i ++)
		for(int j = i; j < i+n; j ++) f[a[i]][j-i][a[j]] ++;
	int x = 0;// puts("orz");
	for(int i = 1; i <= n; i ++) {
		for(int j = i; j < i+n; j ++) {
			x = 0;
			for(int k = 0; k < 26; k ++) {
				if(f[a[i]][j-i][k] == 1) x ++;
			}
			fl[a[i]] = max(x, fl[a[i]]);
		}
	}
	double ans = 0;
	for(int i = 0; i < 26; i ++) if(b[i]) {
		ans += (double)fl[i];// printf("%d\n", fl[i]);
	}
	printf("%.20lf\n", ans/n);
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<map>
#include<math.h>
//#include<time.h>
//#include<complex>
#include<algorithm>
using namespace std;

int n;
#define maxn 5011
char s[maxn];
int f[26][26][maxn]; double ok[26]; int tot[26];
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;i++) tot[s[i]-'a']++;
	for (int i=1;i<=n;i++)
	{
		for (int j=(i==n?1:i+1),cnt=1;j!=i;j=j%n+1,cnt++)
		{
			if (f[s[i]-'a'][cnt][s[j]-'a']==1) f[s[i]-'a'][cnt][s[j]-'a']=-1;
			else if (f[s[i]-'a'][cnt][s[j]-'a']==0) f[s[i]-'a'][cnt][s[j]-'a']=1;
		}
	}
	double ans=0;
	for (int i=0;i<26;i++)
	{
		int now=0;
		for (int j=1;j<n;j++)
		{
			int cnt=0;
			for (int k=0;k<26;k++) if (f[i][j][k]==1) cnt++;
			now=max(now,cnt);
		}
		ok[i]=1.0*now/n; ans+=ok[i];
	}
	printf("%.8lf\n",ans);
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<map>
#include<math.h>
//#include<time.h>
//#include<complex>
#include<algorithm>
using namespace std;

int n;
#define maxn 5011
char s[maxn];
int f[26][maxn][26]; double ok[26]; int tot[26];
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=1;i<=n;i++) tot[s[i]-'a']++;
	for (int i=1;i<=n;i++)
	{
		for (int j=(i==n?1:i+1),cnt=1;j!=i;j=j%n+1,cnt++)
		{
			if (f[s[i]-'a'][cnt][s[j]-'a']==1) f[s[i]-'a'][cnt][s[j]-'a']=-1;
			else if (f[s[i]-'a'][cnt][s[j]-'a']==0) f[s[i]-'a'][cnt][s[j]-'a']=1;
		}
	}
	double ans=0;
	for (int i=0;i<26;i++)
	{
		int now=0;
		for (int j=1;j<n;j++)
		{
			int cnt=0;
			for (int k=0;k<26;k++) if (f[i][j][k]==1) cnt++;
			now=max(now,cnt);
		}
		ok[i]=1.0*now/n; ans+=ok[i];
	}
	printf("%.8lf\n",ans);
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <memory.h>
#include <map>
#define N 111111

using namespace std;

int n;

string s;

int kol;

vector <string> t;

int f[N][300];

void add(string& s)
{
	kol++;
	for (int i=0;i<n;i++) f[i][s[i]]++;
}

void clearF(){
	kol = 0;
	for (int i=0;i<n;i++) for (char c='a'; c<='z'; c++) f[i][c] = 0;
}

double ans = 0.0;

int main(void)
{
 // freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  getline(cin, s);

  n = s.length();

  for (int i=0;i<n;i++)
  {
	t.push_back(s);
	s = s + s[0];
	s.erase(0, 1);
  }

  sort(t.begin(), t.end());

  t.push_back("!");

  add(t[0]);

  for (int i = 1; i<=n; i++) if (t[i][0] != t[i-1][0])
  {
  	int mm = 0;
  	for (int j=1;j<n;j++)
  	{
  		int ma = 0;
  		for (char c = 'a'; c<='z'; c++) if (f[j][c] == 1) ma++;
		mm = max(mm, ma);
  	}
    ans += (kol+ 0.0) / (n + 0.0) * (mm + 0.0)/(kol + 0.0);

  	clearF();
  	add(t[i]);
  } else
  {
  	add(t[i]);
  }
  cout.precision(15);
  cout << ans << endl;

  return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cmath>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

using namespace std;

const int INF=0x3f3f3f3f;
const int N=5005;

int n,pos[729][N],dp[27][N],cnt[27];
char str[N];
double ans;

inline int HASH(int x,int y){return x*26+y;}

void init(){
	scanf("%s",str);
	n=strlen(str);
	for(int i=0;i<n;i++) str[i]-='a',cnt[str[i]]++;
	for(int i=0;i<n;i++){
		for(int t=1;t<n;t++){
			int j=(i+t)%n;
			pos[HASH(str[i],str[j])][t]++;
		}
	}
	for(int i=0;i<26;i++) for(int j=0;j<n;j++) dp[i][j]=true;
	for(int i=0;i<26;i++){
		if(cnt[i]==0) continue;
		double maxp=0;
		for(int j=1;j<n;j++){
			double res=0;
			for(int k=0;k<26;k++){
				int qwq=pos[HASH(i,k)][j];
				if(qwq==1){
					res+=(double)1/cnt[i];
				}
			}
			maxp=max(maxp,res);
		}
		ans+=maxp*cnt[i]/n;
	}
	printf("%.12lf\n",ans);
}

int main(int argc, char** argv) {
	init();
	return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>//memset(a, 0, sizeof(a));

#define maxlongint 2147483647
#define ll long long
#define fo(i, x, y) for (int i = x; i <= y; i++)
#define fd(i, x, y) for (int i = x; i >= y; i--)
#define N 20005
using namespace std;
int n,ans,t,tot,s[N];
int a[26][N];
int q[26];
char c;
void read(int &x) {
	x=0;
	int k=1;char c=getchar();
	while ((c!='-')&&(c<'0'||c>'9')) c=getchar();
	if (c=='-') k=-1,c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	x=x*k;
}
void write(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
void init() {
	freopen("e.in","r",stdin);
	//freopen("e.out","w",stdout);
}
int main() {
	//init();
	c=getchar();
	while (c<'a'||c>'z') c=getchar();
	while (c>='a'&&c<='z') {
		s[++n]=c-'a';
		c=getchar();
	}
	fo(i,n+1,2*n) s[i]=s[i-n];
	fo(i,1,n) {
		a[s[i]][++a[s[i]][0]]=i;
	}
	fo(ii,0,25) {
		t=0;
		fo(j,1,n-1) {
			tot=0;
			memset(q,0,sizeof(q));
			fo(k,1,a[ii][0]) {
				//if (q[s[a[ii][k]+j]]==-1) continue;
				if (q[s[a[ii][k]+j]]==0) {
					q[s[a[ii][k]+j]]=1,tot++;
				} else
				if (q[s[a[ii][k]+j]]==1) {
					q[s[a[ii][k]+j]]=-1,tot--;
				}
			}
			t=max(t,tot);
		}
		ans+=t;
	}
	printf("%.15f\n",double(ans)/double(n));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
int n;
const int maxn = 5e3;
char ax[2*maxn+5];
int dp[maxn+5][30][30];
int bx[30];

int main()
{
    scanf("%s",ax+1);
    n = strlen(ax+1);
    int i,j,k,a,b,ans=0;
    for(i=n+1;i<=2*n;i++){
        ax[i]=ax[i-n];
        bx[ax[i]-'a']++;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=n-1;j++){
            dp[j][ax[i]-'a'][ax[i+j]-'a']++;
        }
    }
    for(i=0;i<26;i++){
        int w=0;
        for(j=1;j<=n-1;j++){
            int h=0;
            for(k=0;k<26;k++)if(dp[j][i][k]==1)h++;
            w = max(h,w);
        }
        ans+=w;
    }
    printf("%.10lf",(double)ans/(double)n);
}


/*program by mangoyang*/
#include<bits/stdc++.h>
#define INF (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
	int f = 0, ch = 0; x = 0;
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
	for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
	if(f) x = -x;
}
char s[5005];
int buf[5005][26], ans, n;
vector<int> v[100];
inline int check(int x){
	if(v[x].size() <= 1) return v[x].size();
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < 26; j++) buf[i][j] = 0;
	for(int i = 0; i < v[x].size(); i++){
		int len = 0;
		for(int j = v[x][i]; j <= n; j++) buf[++len][s[j]-'a']++;
		for(int j = 1; j < v[x][i]; j++) buf[++len][s[j]-'a']++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int now = 0;
		for(int j = 0; j < 26; j++)
			if(buf[i][j] == 1) now++;
		ans = Max(ans, now);
	}
	return ans;
}
int main(){
	scanf("%s", s + 1); n = strlen(s + 1);
	for(int i = 1; i <= n; i++) v[s[i]-'a'].push_back(i);
	for(int i = 0; i < 26; i++) ans += check(i);
		//cout << i << " " << ans << end
	printf("%.6lf", (double) ans /  (double) (n));
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int c[26]={0},dp[26][5005][26]={0};

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
vector<char> v;
rep(i,0,n-1)v.pb(s[i]),c[s[i]-'a']++;
rep(ii,1,n)
{
	char cc=v[0];
	rep(i,1,n-1)
	{
		dp[cc-'a'][i][v[i]-'a']++;
	}
    v.erase(v.begin());
	v.pb(cc);
}
ld ans=0;

rep(i,0,25)
{
	ld nn=n;
	ld num=c[i];
    ld mx=0;
	rep(j,1,n-1)
	{
		int f=0;
		rep(k,0,25)
		{
			if(dp[i][j][k]==1)f++;
		}
		ld fff=f;
		mx=max(mx,fff);
	}

	ans+=(mx/nn);
}
cout<<fixed<<setprecision(10)<<ans;
return 0;
}


#include <bits/stdc++.h>
#include <bitset>

#define ll long long

#define pb push_back

#define f first
#define s second

#define mp make_pair

using namespace std;

const int N = 1e5 + 10;
const int md = 1e9 + 7;
const double EPS = 1e-15;

string s;

int c[30][N][30];

int res;

int main() {
 cin >> s;
 s = s + s;
 for (int i = 0; i < int(s.size()) / 2; i++) {
  for (int j = 1; j < int(s.size()) / 2; j++) {
   c[s[i] - 'a'][j][s[i + j] - 'a']++;
  }
 }
 for (int i = 0; i < 26; i++) {
  int tmp = 0;
  for (int j = 1; j < int(s.size()) / 2; j++) {
   int now = 0;
   for (int k = 0; k < 26; k++) {
    if (c[i][j][k] == 1) now++;
    cout << c[i][j][k] << ' ' << i << ' ' << j << ' ' << k << '\n';
   }
   tmp = max(tmp, now);
  }
  res += tmp;
 }
 cout << fixed << setprecision(15) << res * 2.0 / int(s.size());
 return 0;
}


#include <bits/stdc++.h>
#include <bitset>

#define ll long long

#define pb push_back

#define f first
#define s second

#define mp make_pair

using namespace std;

const int N = 1e5 + 10;
const int md = 1e9 + 7;
const double EPS = 1e-15;

string s;

int c[30][10000][30];

int res;

int main() {
 cin >> s;
 s = s + s;
 for (int i = 0; i < int(s.size()) / 2; i++) {
  for (int j = 1; j < int(s.size()) / 2; j++) {
   c[s[i] - 'a'][j][s[i + j] - 'a']++;
  }
 }
 for (int i = 0; i < 26; i++) {
  int tmp = 0;
  for (int j = 1; j < int(s.size()) / 2; j++) {
   int now = 0;
   for (int k = 0; k < 26; k++) {
    if (c[i][j][k] == 1) now++;
    cout << c[i][j][k] << ' ' << i << ' ' << j << ' ' << k << '\n';
   }
   tmp = max(tmp, now);
  }
  res += tmp;
 }
 cout << fixed << setprecision(15) << res * 2.0 / int(s.size());
 return 0;
}


#include <bits/stdc++.h>
#include <bitset>

#define ll long long

#define pb push_back

#define f first
#define s second

#define mp make_pair

using namespace std;

const int N = 1e5 + 10;
const int md = 1e9 + 7;
const double EPS = 1e-15;

string s;

int c[30][10000][30];

int res;

int main() {
 cin >> s;
 s = s + s;
 for (int i = 0; i < int(s.size()) / 2; i++) {
  for (int j = 1; j < int(s.size()) / 2; j++) {
   c[s[i] - 'a'][j][s[i + j] - 'a']++;
  }
 }
 for (int i = 0; i < 26; i++) {
  int tmp = 0;
  for (int j = 1; j < int(s.size()) / 2; j++) {
   int now = 0;
   for (int k = 0; k < 26; k++) {
    if (c[i][j][k] == 1) now++;
   }
   tmp = max(tmp, now);
  }
  res += tmp;
 }
 cout << fixed << setprecision(15) << res * 2.0 / int(s.size());
 return 0;
}


/*
 * =template=.cpp
 * Copyright (C) 2017 hzw <hzw@huzhenweideMacBook.local>
 *
 * Distributed under terms of the MIT license.
 */

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<cstring>
#include<sstream>
#define FR first
#define SC second
#define MP make_pair
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N=100010;
const int p=1000000007;
int pow(int a,int b,int c)
{
    if (a==0)return 0;
    int d=a,e=1;
    while (b)
    {
        if (b&1) e=(1LL*e*d)%c;
        d=1LL*d*d%c;
        b>>=1;
    }
    return e;
}
int random(int n) { return 1LL*rand()*rand()%n+1;}
int n,m,ans;
int d[N],c[N],a[N];
char s[N*2];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for (int i=0;i<n;i++) s[i+n]=s[i],c[s[i]-'a']++;
	for (int i=0;i<26;i++)
	if (c[i]>0)
	{
		int t=0,num=0;
		for (int j=0;j<n;j++) if (s[j]==i+'a') a[num++]=j;
		for (int j=1;j<n;j++)
		{
			int tmp=0;
			for (int k=0;k<26;k++) d[k]=0;
			for (int k=0;k<num;k++) d[s[a[k]+j]-'a']++;
			for (int k=0;k<26;k++) if (d[k]==1) tmp++;
			t=max(t,tmp);
		}
		ans+=t;
	}
	printf("%.9f\n",ans*1.0/n);
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#define N 5002
#define K 26
using namespace std;
int n;
int sum[K];
char str[N];
char str_list[N][N];
int main(){
	double ans = 0.0;
	scanf("%s",str),n = strlen(str);
	for(int i=0;i<26;i++){
		int cnt = 0;
		int max_total = 0;
		for(int j=0;j<n;j++) if(str[j] == 'a' + i){
			for(int k=j;k<n;k++)str_list[cnt][k - j] = str[k];
			for(int k=0;k<j;k++)str_list[cnt][k + n - j] = str[k];
			cnt++;
		}
		for(int j=1;j<n;j++){
			int total = 0;
			for(int k=0;k<K;k++) sum[k] = 0;
			for(int k=0;k<cnt;k++)sum[(int)(str_list[k][j] - 'a')]++;
			for(int k=0;k<K;k++) if(sum[k] == 1)total++;
			max_total = max(max_total,total);
		}
		ans += 1.0 * max_total / (1.0 * n);
	}
	printf("%.10lf\n",ans);
	return 0;
}


#include<cstring>
#include<cstdio>
#define N 5010
#define fo(i,a,b) for(int i=a,E=b;i<=E;i++)

using namespace std;

int k[26],a[N+N],p[N],t,n,tot;
double ans=0.0;
char c;

int main(){
//	freopen("b.in","r",stdin);
//	freopen("b.out","w",stdout);
	for(;(c=getchar())>='a' && c<='z';)a[++n]=c-'a';
	fo(i,n+1,n+n)a[i]=a[i-n];
	fo(l,0,25){
		t=0;
		fo(i,1,n)if(a[i]==l)p[++t]=i;
		if(!t)continue;++tot;
		int s=0,cnt;
		fo(i,1,n){
			cnt=0;
			memset(k,0,sizeof k);
			fo(j,1,t)++k[a[p[j]+i]];
			fo(j,0,25)if(k[j]==1)++cnt;
			if(cnt>s)s=cnt;
		}
		ans+=(double)s/n;
	}printf("%.10lf",ans);
	fclose(stdin);fclose(stdout);
	return 0;
}


#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int n,i,j,k,l,x,dp[26][26][5020],sum[26],ans,ans2,flag,flag2;
char s[5020][5020];
double u,v,w;
int main(){
	scanf("%s",&s[1]);
	n=strlen(s[1]);
	for(i=2;i<=n;i++)
		for(j=0;j<n;j++)
			s[i][j]=s[i-1][(j+1)%n];
	for(i=1;i<=n;i++){
		sum[s[i][0]-'a']++;
		for(j=1;j<n;j++)
			dp[s[i][0]-'a'][s[i][j]-'a'][j]++;
	}
	for(i=0;i<=25;i++){
		for(j=0;j<n;j++){
			for(k=0;k<=25;k++)
				if(dp[i][k][j]==1)
					flag++;
			flag2=max(flag,flag2);
			flag=0;
		}
		ans+=flag2;
		flag2=0;
	}
	u=ans*1.0;
	v=n*1.0;
	w=u/v;
	printf("%.10lf\n",w);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
    char s;
    int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);
    if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
inline void write(int x)
{
    static char cnt,num[15];cnt=0;
    if (!x)
    {
        putchar('0');
        return;
    }
    for (;x;x/=10) num[++cnt]=x%10;
    for (;cnt;putchar(num[cnt--]+48));
}
char ch[5010];
int Map[27][5010][27],n,s1,s2,s3,s4;
int cnt[27];
double ans,sum;
int main()
{
#ifdef ylx
    freopen("cf930b.in","r",stdin);
    freopen("cf930b.out","w",stdout);
#endif
    scanf("%s",ch);
    n=strlen(ch);
    for (int i=0;i<n;i++)
    {
        cnt[ch[i]-'a']++;
        for (int j=1;j<n;j++)
        {
            Map[ch[i]-'a'][j][ch[(i+j)%n]-'a']++;
        }
    }
    s2=n;
    s1=0;
    for (int i=0;i<26;i++)
    {
		int sum=0,t=0;
        for (int j=1;j<n;j++)
        {
			sum=0;
			for (int k=0;k<26;k++)
            if (Map[i][j][k]==1) sum++;
           	qmax(t,sum);
        }
		s1+=t;
    }
    ans=(double)s1/s2;
    printf("%.8f",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> V[26];
int win[26];
int m[26];

bool cmp(pair<char, int> P1, pair<char, int> P2){
	return P1.first < P2.first;
}

int main(){
	string a;
	cin >> a;
	double n = a.length();
	for(int i = 0;i < a.length();++i){
		V[a[i] - 'a'].push_back(i);
	}
	for(int i = 0;i < 26;++i){
		if((int)V[i].size() == 1) win[V[i][0]] = 1;
		else if((int)V[i].size() == 0) continue;
		else{
			int ans = 0;
			int cnt2 = 0;
			for(int j = 1;j < n;++j){
				vector<pair<char, int> > VV;
				for(int q = 0;q < (int)V[i].size();++q){
					int ind = (V[i][q] + j) % (a.length());
					VV.push_back(make_pair(a[ind], V[i][q]));
				}
				sort(VV.begin(), VV.end(), cmp);
				for(int q = 0;q < (int)VV.size();++q){
					int cnt = 0;
					while((q + 1) < n && VV[q].first == VV[q + 1].first){
						cnt++;
						q++;
					}
					if(cnt == 0) cnt2++;
				}
				ans = max(ans, cnt2);
				cnt2 = 0;
			}
			win[i] = ans;
		}
	}
	int cnt = 0;
	for(int i = 0;i < 26;++i){
		cnt+=win[i];
	}
	cout << fixed;
	cout.precision(9);
	cout << (double)cnt / n;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
vector<int> V[26];
int win[26];

int main(){
	string a;
	cin >> a;
	double n = a.length();
	for(int i = 0;i < a.length();++i){
		V[a[i] - 'a'].push_back(i);
	}
	for(int i = 0;i < 26;++i){
		if((int)V[i].size() == 1) win[i] = 1;
		else if((int)V[i].size() == 0) continue;
		else{
			int ans = 0;
			int cnt2 = 0;
			for(int j = 0;j < n;++j){
				vector<int> VV;
				for(int q = 0;q < (int)V[i].size();++q){
					int ind = (V[i][q] + j) % (a.length());
					VV.push_back(a[ind]);
				}
				sort(VV.begin(), VV.end());
				for(int q = 0;q < (int)VV.size();++q){
					int cnt = 0;
					while((q + 1) < (int)VV.size() && VV[q] == VV[q + 1]){
						cnt++;
						q++;
					}
					if(cnt == 0) cnt2++;
				}
				ans = max(ans, cnt2);
				cnt2 = 0;
			}
			win[i] = ans;
		}
	}
	int cnt = 0;
	for(int i = 0;i < 26;++i){
		cnt+=win[i];
	}
	cout << fixed;
	cout.precision(9);
	cout << (double)cnt / n;
	return 0;
}


#include<cstdio>
#include<cstring>
#define fo(i, x, y) for(int i = x; i <= y; i ++)
#define max(a, b) ((a) > (b) ? (a) : (b))
using namespace std;

const int N = 1e4 + 5;

char s[N]; int n, d[N], sum[N][26];

int final[N], next[N], to[N], tot, ans;

void link(int x, int y) {
	next[++ tot] = final[x], to[tot] = y, final[x] = tot;
}

int main() {
//	freopen("b.in", "r", stdin);
	scanf("%s", s + 1); n = strlen(s + 1);
	fo(i, n + 1, 2 * n) s[i] = s[i - n];
	fo(i, 1, n) link(s[i] - 'a', i);
	fo(i, 0, 25) {
		d[0] = 0;
		for(int j = final[i]; j; j = next[j])
			d[++ d[0]] = to[j];
		fo(j, 1, n) memset(sum[j], 0, sizeof sum[j]);
		fo(j, 1, d[0]) {
			int x = d[j];
			fo(k, x, x + n - 1) sum[k - x + 1][s[k] - 'a'] ++;
		}
		int mx = 0;
		fo(j, 2, n) {
			int y = 0;
			fo(k, 0, 25) if(sum[j][k] == 1) y ++;
			mx = max(mx, y);
		}
		ans += mx;
	}
	printf("%.10lf", (double) ans / n);
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=5010;

int n,a[maxn],ch[30];
double ans;
char s[maxn][maxn];
double solve(char c){
	int tot=0;
	for(int i=0;i<n;i++)if(s[i][0]==c)a[++tot]=i;
	for(int j=0;j<n;j++){
		memset(ch,0,sizeof(ch));
		for(int i=1;i<=tot;i++){
			ch[s[a[i]][j]-'a']++;
		}
		for(int i=0;i<26;i++)if(ch[i]==1){
			if(tot==2){
				return 1.0*tot/n;
			}
			else{
				return 1.0/n;
			}
		}
	}
	return 0;
}
char ss[maxn];
int main(){
    scanf("%s",ss);
    n=strlen(ss);
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++)s[i][j]=ss[(i+j)%n];
    }
    ans=0;
    for(int i=0;i<26;i++)ans+=solve('a'+i);
    printf("%.10lf",ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=5010;

int n,a[maxn],ch[30],ans;
char s[maxn][maxn];
int solve(char c){
	int tot=0,mx=0;
	for(int i=0;i<n;i++)if(s[i][0]==c)a[++tot]=i;
	for(int j=0;j<n;j++){
		memset(ch,0,sizeof(ch));
		for(int i=1;i<=tot;i++){
			ch[s[a[i]][j]-'a']++;
		}
		int now=0;
		for(int i=0;i<26;i++)now+=(ch[i]==1);
		mx=max(mx,now);
	}
	return mx;
}
char ss[maxn];
int main(){
    scanf("%s",ss);
    n=strlen(ss);
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++)s[i][j]=ss[(i+j)%n];
    }
    ans=0;
    for(int i=0;i<26;i++)ans+=solve('a'+i);
    printf("%.10lf",1.0*ans/n);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=5010;

int n,a[maxn],ch[30],ans;
char s[maxn][maxn];
int solve(char c){
	int tot=0;
	for(int i=0;i<n;i++)if(s[i][0]==c)a[++tot]=i;
	for(int j=0;j<n;j++){
		memset(ch,0,sizeof(ch));
		for(int i=1;i<=tot;i++){
			ch[s[a[i]][j]-'a']++;
		}
		for(int i=0;i<26;i++)if(ch[i]==1){
			if(tot==2){
				return tot;
			}
			else{
				return 1;
			}
		}
	}
	return 0;
}
char ss[maxn];
int main(){
    scanf("%s",ss);
    n=strlen(ss);
    for(int i=0;i<n;i++){
    	for(int j=0;j<n;j++)s[i][j]=ss[(i+j)%n];
    }
    ans=0;
    for(int i=0;i<26;i++)ans+=solve('a'+i);
    printf("%.10lf",1.0*ans/n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

//	suffix array in O(N*logN^2).
struct suffixArray{
	//constant parameters.
	static const int LOGN = 20;

	int *rank;
	int *sparse_rank[LOGN];
	int *SA;
	int n;
	string str;

	suffixArray(string s){
		str = s;
		n = s.length();
		SA = (int*)malloc(sizeof(int)*n);
		rank = (int*)malloc(sizeof(int)*n);
		for(int i=0;i<LOGN;i++){
			sparse_rank[i] = (int*)malloc(sizeof(int)*n);
		}

		int temp[26];
		for(int i=0;i<26;i++){
			temp[i] = 0;
		}
		for(int i=0;i<n;i++){
			temp[s[i]-'a'] = 1;
		}
		for(int i=1;i<26;i++){
			temp[i] += temp[i-1];
		}
		int rank[n];
		for(int i=0;i<n;i++){
			rank[i] = temp[s[i]-'a'];
			sparse_rank[0][i] = rank[i];
		}

		int f = 1;
		for(int i=1;i<LOGN;i++){	//	upto LOGN
			vector<pair<pair<int,int>,int> > vc;
			for(int j=0;j<n;j++){
				int val = -1;
				if(j + f < n){
					val = rank[j+f];
				}
				vc.push_back(make_pair(make_pair(rank[j],val),j));
			}
			sort(vc.begin(),vc.end());
			int ptr = 1;
			for(int l=0;l<vc.size();l++){
				int j = l;
				while(j < n && vc[j].first == vc[l].first){
					rank[vc[j].second] = ptr;
					sparse_rank[i][vc[j].second] = ptr;
					j++;
				}
				ptr++;
				l = j - 1;
			}
			f *= 2;
		}	//	done :) ,complexity O(N*logN^2).
		vector<pair<int,int> > vc;
		for(int i=0;i<n;i++){
			vc.push_back(make_pair(rank[i],i));
		}
		sort(vc.begin(),vc.end());
		for(int i=0;i<vc.size();i++){
			SA[i] = vc[i].second;
		}
	}

	int LCP(int i,int j){
		int st1 = SA[i];
		int st2 = SA[j];
		int len = 0;
		int f = (1<<(LOGN-1));
		int lg = LOGN-1;
		while(st1 < n && st2 < n && lg >= 0){
			if(st1 + f <= n && st2 + f <= n && sparse_rank[lg][st1] == sparse_rank[lg][st2]){
				st1 += f;
				st2 += f;
				len += f;
			}
			f = f >> 1;
			lg--;
		}
		return len;
	}

	void solve(){
	}
};

int main(){
	string s;
	cin>>s;
	s = s + s;
	int l = s.length();
	int n = l / 2;
	static int dp[26][5005][26];
	static bool vis[26];
	static int acc[26];
	long double cnt =0 ;
	for(int i=0;i<n;i++){
		if(vis[s[i]-'a']){

		} else {
			cnt += 1.0;
			vis[s[i]-'a'] = true;
		}
		acc[s[i]-'a']++;
		for(int j=i;j<(i+n);j++){
			dp[s[i]-'a'][j-i][s[j]-'a']++;
		}
	}
	long double ans = 0.0;
	for(int i=0;i<26;i++){
		if(vis[i]){

		} else {
			continue;
		}
		long double pr = (acc[i]*1.0) / n;
		long double ma = 0.0;
		for(int j=0;j<n;j++){
			long double infavour = 0.0;
			long double total = 0.0;
			for(int k=0;k<26;k++){
				if(dp[i][j][k] == 1){
					infavour += dp[i][j][k];
					total += dp[i][j][k];
				} else
				if(dp[i][j][k]){
					total += dp[i][j][k];
				}
			}
			if(total > 0){
				ma = max(ma, infavour/total);
			}
		}
		ans += pr * ma;
	}
	cout<<setprecision(8)<<fixed;
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>  //testing
using namespace std;

const int maxn = 5000+5;
char str[maxn*2];
int a[26][26][maxn];
int tot,n;

int main(){
    scanf("%s",str+1);
    n = strlen(str+1);
    for (int i=1; i<=n; i++) str[i+n] = str[i];
    memset(a,0,sizeof(a));
    for (int i=1; i<=n; i++)
        for (int j=i+1; j<i+n; j++) a[str[i]-'a'][str[j]-'a'][j-i+1]++;

    tot = 0;
    for (int i=0; i<26; i++) {
        int tmp = 0;
        for (int j=1; j<=n; j++) {
            int sum = 0;
            for (int k=0; k<26; k++) if (a[i][k][j]==1) sum++;
            tmp = max(sum,tmp);
        }
        tot += tmp;
    }
    printf("%.14f\n",double(tot)/n);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<bitset>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
#define MAXN 5010
#define MAXM 1010
#define INF 1000000000
#define MOD 1000000007
#define eps 1e-8
#define ll long long
char s[MAXN*2];
int has[26][26][MAXN];
int n;
double ans;
int cnt[26];
int main(){
	int i,j,k;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++){
		s[n+i]=s[i];
		cnt[s[i]-'a']++;
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<i+n;j++){
			has[s[i]-'a'][s[j]-'a'][j-i]++;
		}
	}
	for(i=0;i<26;i++){
		double p=0;
		for(j=i+1;j<i+n;j++){
			double t=0;
			for(k=0;k<26;k++){
				if(has[i][k][j-i]==1){
					t++;
				}
			}
			p=max(p,t/cnt[i]);
		}

		ans+=p*cnt[i];
	}
	cout<<1.*ans/n<<endl;
	return 0;
}

/*

*/


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

int main(){
	int ans = 0;
	string s;
	vector<int> v[26];

	cin >> s;
	int tmp = s.length();
	for(int i = 0; i < tmp; i++){
		v[s[i] - 'a'].push_back(i);
		s = s + s[i];
	}

	for(int i = 0; i < 26; i++){
		int sum = 0;
		for(int k = 1; k < tmp - 1; k++){
			int res = 0, cha[26];
			memset(cha, 0, sizeof(cha));
			for(int j = 0; j < v[i].size(); j++){
				int n = v[i][j] + k;
				if(cha[s[n] - 'a'] == 0){
					cha[s[n] - 'a']++;
					res++;
				}
				else res--;
			}
			sum = max(res, sum);
		}
		ans += sum;
	}

	printf("%.14f\n", double(ans) / tmp);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
struct arr{int x,y,z;}Q[N*N<<1];
char s[N][N];
int n,m,mx,ans,tot,f[N],g[N],h[N],p[N],v[N];
inline bool cmp(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x>y.x;
}
inline void add(int x)
{
	for(;x;x-=x&-x)v[x]++;
}
inline int ask(int x)
{
	int tmp=0;for(;x<=mx;x+=x&-x)tmp+=v[x];return tmp;
}
int main()
{
	scanf("%d%d",&n,&m);getchar();
	for(int i=1;i<=n;getchar(),i++)
		for(int j=1;j<=m;j++)s[i][j]=getchar();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')f[j]++;else f[j]=0;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')g[j]++;else g[j]=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')p[j]++;else p[j]=0;
	for(int i=m;i>=1;i--)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')h[j]++;else h[j]=0;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)if(h[i]==m)ans++;
	for(int i=2;i<m;i++)if(f[i]==n)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<n;j++)if(i!=j){
			int R=h[i],L=p[j],tmp=R+L-m;
			if(R+L<=m||R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);mx=f[j];
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=h[i],L=h[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);mx=f[j];
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=p[i],L=p[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,m-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=m-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);mx=f[j];
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=2;j<m;j++)if(i!=j){
			int R=g[i],L=f[j],tmp=R+L-n;
			if(R+L<=n||R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);mx=max(mx,h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=g[i],L=g[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);mx=max(mx,h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=f[i],L=f[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,n-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=n-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);mx=0;
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);mx=max(mx,h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	printf("%d\n",ans);
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
struct arr{int x,y,z;}Q[N*N<<1];
char s[N][N];
int n,m,ans,tot,f[N],g[N],h[N],p[N],v[N];
inline bool cmp(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x>y.x;
}
void add(int x)
{
	for(;x;x-=x&-x)v[x]++;
}
int ask(int x)
{
	int tmp=0;for(;x<=2000;x+=x&-x)tmp+=v[x];return tmp;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')f[j]++;else f[j]=0;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')g[j]++;else g[j]=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')p[j]++;else p[j]=0;
	for(int i=m;i>=1;i--)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')h[j]++;else h[j]=0;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)if(h[i]==m)ans++;
	for(int i=2;i<m;i++)if(f[i]==n)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<n;j++)if(i!=j){
			int R=h[i],L=p[j],tmp=R+L-m;
			if(R+L<=m||R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=h[i],L=h[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=p[i],L=p[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,m-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=m-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=2;j<m;j++)if(i!=j){
			int R=g[i],L=f[j],tmp=R+L-n;
			if(R+L<=n||R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=g[i],L=g[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=f[i],L=f[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,n-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=n-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	printf("%d\n",ans);
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
struct arr{int x,y,z;}Q[N*N<<1];
char s[N][N];
int n,m,ans,tot,f[N],g[N],h[N],p[N],v[N];
inline bool cmp(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x>y.x;
}
void add(int x)
{
	for(;x;x-=x&-x)v[x]++;
}
int ask(int x)
{
	int tmp=0;for(;x<=2000;x+=x&-x)tmp+=v[x];return tmp;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')f[j]++;else f[j]=0;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')g[j]++;else g[j]=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')p[j]++;else p[j]=0;
	for(int i=m;i>=1;i--)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')h[j]++;else h[j]=0;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)if(h[i]==m)ans++;
	for(int i=2;i<m;i++)if(f[i]==n)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<n;j++)if(i!=j){
			int R=h[i],L=p[j],tmp=R+L-m;
			if(R+L<=m||R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=h[i],L=h[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=p[i],L=p[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,m-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=m-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=2;j<m;j++)if(i!=j){
			int R=g[i],L=f[j],tmp=R+L-n;
			if(R+L<=n||R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=g[i],L=g[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=f[i],L=f[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,n-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=n-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	printf("%d\n",ans);
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
struct arr{int x,y,z;}Q[N*N<<1];
char s[N][N];
int n,m,ans,tot,f[N],g[N],h[N],p[N],v[N];
inline bool cmp(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x>y.x;
}
void add(int x)
{
	for(;x;x-=x&-x)v[x]++;
}
int ask(int x)
{
	int tmp=0;for(;x<=2000;x+=x&-x)tmp+=v[x];return tmp;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')f[j]++;else f[j]=0;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')g[j]++;else g[j]=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')p[j]++;else p[j]=0;
	for(int i=m;i>=1;i--)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')h[j]++;else h[j]=0;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)if(h[i]==m)ans++;
	for(int i=2;i<m;i++)if(f[i]==n)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<n;j++)if(i!=j){
			int R=h[i],L=p[j],tmp=R+L-m;
			if(R+L<=m||R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=h[i],L=h[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=p[i],L=p[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,m-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=m-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=2;j<m;j++)if(i!=j){
			int R=g[i],L=f[j],tmp=R+L-n;
			if(R+L<=n||R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=g[i],L=g[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=f[i],L=f[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,n-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=n-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	printf("%d\n",ans);
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 2006
using namespace std;
struct arr{int x,y,z;}Q[N*N<<1];
char s[N][N];
int n,m,tot,f[N],g[N],h[N],p[N],v[N];long long ans;
inline bool cmp(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x<y.x;
}
inline bool cmp2(arr x,arr y)
{
	if(x.x==y.x)return x.y<y.y;
	return x.x>y.x;
}
void add(int x)
{
	for(;x;x-=x&-x)v[x]++;
}
int ask(int x)
{
	int tmp=0;for(;x<=2000;x+=x&-x)tmp+=v[x];return tmp;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')f[j]++;else f[j]=0;
	for(int i=n;i>=1;i--)
		for(int j=1;j<=m;j++)if(s[i][j]=='.')g[j]++;else g[j]=0;
	for(int i=1;i<=m;i++)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')p[j]++;else p[j]=0;
	for(int i=m;i>=1;i--)
		for(int j=1;j<=n;j++)if(s[j][i]=='.')h[j]++;else h[j]=0;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&g[j]>=i)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(h[i]>=j&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<m;j++)if(p[i]>=m-j+1&&f[j]>=n-i+1)ans++;
	for(int i=2;i<n;i++)if(h[i]==m)ans++;
	for(int i=2;i<m;i++)if(f[i]==n)ans++;
	for(int i=2;i<n;i++)
		for(int j=2;j<n;j++)if(i!=j){
			int R=h[i],L=p[j],tmp=R+L-m;
			if(R+L<=m||R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=h[i],L=h[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=min(m-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<n;i++)
		for(int j=i+2;j<n;j++){
			int R=p[i],L=p[j];
			if(R<2||L<2)continue;
			Q[++tot].x=max(i,j);Q[tot].y=max(2,m-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=max(i,j);Q[tot].y=m-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp);
	memset(f,0,sizeof f);
	for(int i=1,k=1;i<=n;i++){
		memset(v,0,sizeof v);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='.')f[j]++;else f[j]=0;add(f[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=2;j<m;j++)if(i!=j){
			int R=g[i],L=f[j],tmp=R+L-n;
			if(R+L<=n||R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,R-tmp+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,R);Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=g[i],L=g[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=min(n-1,min(L,R));Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	for(int i=2;i<m;i++)
		for(int j=i+2;j<m;j++){
			int R=f[i],L=f[j];
			if(R<2||L<2)continue;
			Q[++tot].x=min(i,j);Q[tot].y=max(2,n-min(L,R)+1)-1;Q[tot].z=-(max(i,j)-min(i,j)+1);
			Q[++tot].x=min(i,j);Q[tot].y=n-1;Q[tot].z=max(i,j)-min(i,j)+1;
		}
	sort(Q+1,Q+tot+1,cmp2);
	memset(h,0,sizeof h);
	for(int i=m,k=1;i>=1;i--){
		memset(v,0,sizeof v);
		for(int j=1;j<=n;j++){
			if(s[j][i]=='.')h[j]++;else h[j]=0;add(h[j]);
			while(Q[k].x==i&&Q[k].y==j&&k<=tot){
				if(Q[k].z<0){
					Q[k].z=-Q[k].z;
					ans-=ask(Q[k].z);
				}else ans+=ask(Q[k].z);
				k++;
			}
		}
	}
	tot=0;
	printf("%lld\n",ans);
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie() , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 2020
#define INF 0x3f3f3f3f

int n , m;
long long ans;
int u[MAX][MAX] , d[MAX][MAX] , l[MAX][MAX] , r[MAX][MAX];
string s[MAX] , ss[MAX];
void solveinit(){
    REP(i , 0 , n) l[i][0] = (s[i][0] == '.') ? 1 : 0;
    REP(i , 0 , m) u[0][i] = (s[0][i] == '.') ? 1 : 0;
    REP(i , 0 , n) r[i][m - 1] = (s[i][m - 1] == '.') ? 1 : 0;
    REP(i , 0 , m) d[n - 1][i] = (s[n - 1][i] == '.') ? 1 : 0;

    REP(i , 0 , n) REP(j , 1 , m) l[i][j] = l[i][j - 1] * (s[i][j] == '.');
    REP(i , 1 , n) REP(j , 0 , m) u[i][j] = u[i - 1][j] * (s[i][j] == '.');
    REP(i , 0 , n) RREP(j , m - 2 , 0) r[i][j] = r[i][j + 1] * (s[i][j] == '.');
    RREP(i , n - 2 , 0) REP(j , 0 , m) d[i][j] = d[i + 1][j] * (s[i][j] == '.');
}
void solve(){
    solveinit();

    // REP(i , 0 , n){
    //     REP(j , 0 , m) cout << s[i][j] << " ";
    //     cout << endl;

    // } cout << "----" << endl;
    // REP(i , 0 , n){
    //     REP(j , 0 , m) cout << u[i][j] << " " ;
    //     cout << endl;
    // } cout << "&&&&&&&" << endl;

    REP(i , 1 , m - 1) if(d[0][i]) ans ++;
    REP(i , 1 , n - 1) REP(j , 1 , m - 1){
        if(r[i][j] && d[i][j]) ans ++;
        if(l[i][j] && u[i][j]) ans ++;
    }
    REP(i , 1 , n - 1){
        int up = 0 , dw = 0;
        REP(j , 1 , m - 1){
            if(s[i][j] == '#') up = 0 , dw = 0;
            else {
                if(u[i][j]){
                    ans += up + dw;
                    if(u[i][j - 1] && j - 1 > 0) ans --;
                }
                if(d[i][j]){
                    ans += up + dw;
                    if(d[i][j - 1] && j - 1 > 0) ans --;
                }
                if(u[i][j]) up ++;
                if(d[i][j]) dw ++;
            }
        }
    }
}
int32_t main(){
    IOS;
    cin >> n >> m;
    REP(i , 0 , n) cin >> s[i];
    solve();
    REP(i , 0 , m) ss[i].resize(n);
    REP(i , 0 , n) REP(j , 0 , m) ss[j][n - 1 - i] = s[i][j];
    REP(i , 0 , m) s[i] = ss[i];
    swap(n , m);
    solve();
    cout << ans << endl;
    return 0;
}