#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    x %= 11;
    if (x==0) {;}
    else if (x<=6) ans++;
    else ans += 2;
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
  string s;
  cin >> s;
  int n = s.size();
  reverse(rng(s));
  bool ok = false;
  int cnt = 0, nt = 0;
  rep(i,n) {
    if(s[i]=='T') nt++;
    if(!ok&&s[i]=='T') ok = true;
    else if(ok&&s[i]=='S'&&nt>0) {
      cnt++;
      nt--;
    }
  }
  int ans = n-cnt*2;
  if(ans<0) ans = 0;
  cout << ans << endl;
  return 0;
}