#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

char ba[100][100];

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

struct P {
  int y, x;
  int d;
  int a, b;
  P(int y, int x, int d, int a, int b) : y(y),x(x),a(a),b(b),d(d) {}
};

bool ok[100][100][4][11][11];

int main() {
  int h, w, A;
  while(cin>>h>>w>>A) {
    int sx, sy;
    int gx, gy;
    REP(i,h) REP(j, w) {
      cin >> ba[i][j];
      if (ba[i][j] == 'S') {
        sy = i;
        sx = j;
      } else if (ba[i][j] == 'G') {
        gy = i;
        gx = j;
      }
    }
    queue<P> Q;
    memset(ok, 0, sizeof(ok));
    Q.push(P(sy,sx,1,A, A));
    bool hoge = 0;
    while(!Q.empty()) {
      P p = Q.front(); Q.pop();
      if (ok[p.y][p.x][p.d][p.a][p.b]) continue;
      ok[p.y][p.x][p.d][p.a][p.b] = 1;

      //cout << p.x << " " << p.y << " " << p.d << " " << p.a << " " <<p.b << endl;
      int yy = p.y + dy[p.d];
      int xx = p.x + dx[p.d];
      if (ba[p.y][p.x] == 'S' && p.d == 3) continue;
      if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
        Q.push(P(yy,xx,p.d,p.a,p.b));

      if (ba[p.y][p.x] == 'S') continue;
      
      if (p.a) {
        int yy, xx;
        int dd;
        if (p.d % 2) {
          dd = (p.d+3)%4;
        } else {
          dd = (p.d+1)%4;
        }
        yy = p.y + dy[dd];
        xx = p.x + dx[dd];
        if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
          Q.push(P(yy,xx,dd,p.a-1,p.b));
      }
      if (p.b) {
        int yy, xx;
        int dd;
        if (p.d % 2) {
          dd = (p.d+1)%4;
        } else {
          dd = (p.d+3)%4;
        }
        yy = p.y + dy[dd];
        xx = p.x + dx[dd];
        if (!(yy<0||yy>=h||xx<0||xx>=w || ba[yy][xx] == '#'))
          Q.push(P(yy,xx,dd,p.a,p.b-1));
      }
    }
    int ans = -1;
    REP(i, 4) {
      REP(j, A+1) {
        REP(k, A+1) {
          if (ok[gy][gx][i][j][k]) {
            //cout << i << "," << j <<"," << k << endl;
            if (ans == -1) ans = A*2-(j+k);
            else ans = min(ans, A*2-(j+k));
          }
        }
      }
    }
    cout << ans << endl;
  }
}