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

int a, b, c;
double dp[105][105][105];

double solve(int a, int b, int c) {
    if(dp[a][b][c])
        return dp[a][b][c];
    if(a==100 or b==100 or c==100)
        return 0;
    double ans = 0;
    ans += (solve(a+1,b,c)+1)*a/(a+b+c);
    ans += (solve(a,b+1,c)+1)*b/(a+b+c);
    ans += (solve(a,b,c+1)+1)*c/(a+b+c);
    dp[a][b][c] = ans;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> a >> b >> c;
    cout << setprecision(10) << fixed << solve(a, b, c);
    return 0;
}



//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define P pair<ll,ll>
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;
const ll M = 1000000007;

ll lmax(ll x,ll y){
  if(x < y) return y;
  else return x;
}

ll lmin(ll x, ll y){
  if(x > y)return y;
  else return x;
}

ll gen(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y%2 == 1){
    return ((x%M)*gen(x,y-1)%M)%M;
  }else{
    ll res = gen(x,y/2)%M;
    return ((res%M)*(res%M))%M;
  }
}

ll gcd(ll x, ll y){
  if(x < y) swap(x,y);
  if(y == 0) return x;
  return gcd(y,x%y);
}

ll lcm(ll x,ll y){
  ll s = gcd(x,y);
  x /= s;
  y /= s;
  return x*y*s;
}

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) cin >> a[i];
  pair<int,int> s,g;
  vector<vector<pair<int,int>>>  p(26);
  vector<int> sumi(26,1);
  rep(i,h)rep(j,w){
    if(a[i][j] == 'S'){
      s.first = i;
      s.second = j;
    }
    else if(a[i][j] == 'G'){
      g.first = i;
      g.second = j;
    }else if(a[i][j] != '.' && a[i][j] != '#'){
      char mozi = a[i][j];
      p[mozi-'a'].push_back(make_pair(i,j));
    }else{
      continue;
    }
  }
  queue<pair<int,int>> q;
  vector<int> di = {0,1,0,-1}, dj = {1,0,-1,0};
  vector<vector<int>> ans(h,vector<int>(w,-1));
  ans[s.first][s.second] = 0;
  q.push(s);
  ll cnt = 0;
  while(!q.empty()){
    int i = q.front().first,j = q.front().second;
    rep(k,4){
      cnt++;
      int ni = i+di[k],nj = j+dj[k];
      if(ni < 0 || ni >= h || nj < 0 || nj >= w)continue;
      if(a[ni][nj] == '#')continue;
      if(a[ni][nj] == 'S')continue;
      if(a[ni][nj] == 'G'){
        if(ans[ni][nj] == -1) ans[ni][nj] = ans[i][j] + 1;
        else ans[ni][nj] = min(ans[i][j] + 1,ans[ni][nj]);
      }
      else if(a[ni][nj] == '.'){
        if(ans[ni][nj] == -1){
          ans[ni][nj] = ans[i][j] + 1;
          q.push(make_pair(ni,nj));
        }else if(ans[ni][nj] <= ans[i][j]+1){
          continue;
        }else{
          ans[ni][nj] = ans[i][j] + 1;
          q.push(make_pair(ni,nj));
        }
      }else{
        char m = a[i][j];
        if(a[ni][nj] != m){
          if(ans[ni][nj] == -1){
            ans[ni][nj] = ans[i][j] + 1;
            q.push(make_pair(ni,nj));
          }else if(ans[ni][nj] <= ans[i][j]+1){
            continue;
          }else{
            ans[ni][nj] = ans[i][j] + 1;
            q.push(make_pair(ni,nj));
          }
        }
      }
    }
    if(a[i][j] != 'S' && a[i][j] != 'G' && a[i][j] != '.' && a[i][j] != '#' && sumi[a[i][j]-'a'] == 1){
      for(auto x : p[a[i][j]-'a']){
        cnt++;
        if(x.first == i && x.second == j)continue;
        if(ans[x.first][x.second] == -1){
          ans[x.first][x.second] = ans[i][j] + 1;
          q.push(make_pair(x.first,x.second));
        }else if(ans[x.first][x.second] <= ans[i][j]+1){
          continue;
        }else{
          ans[x.first][x.second] = ans[i][j] + 1;
          q.push(make_pair(x.first,x.second));
        }
      }
      sumi[a[i][j]-'a'] = 0;
    }



    q.pop();
    cnt++;
  }
  cout << ans[g.first][g.second] << endl;

  return 0;
}
