#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b


signed main(){
	string s; cin>>s;
	int n=s.size();
	ll ans=0;
	ll cnt=0;
	rep(i,0,n){
		if(s[i]=='S')cnt++;
		else if(cnt>0){
			cnt--;
			ans++;
		}
	}
	cout<<n-(ans*2)<<endl;
	
	
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007

void solve()
{
	ll x;
	cin>>x;
	if(x<=6)
		cout<<1;
	else if(x<=11)
		cout<<2;
	else if(x%11>6)
		cout<<(x/11)*2+2;
	else if(x%11==0)
		cout<<(x/11)*2;
	else
		cout<<(x/11)*2+1;
	return;
}

int main()
{
	fast;
	ll q=1;
	// cin>>q;
	while(q--)
		solve();
	return 0;
}

