#include<ctime>
#include<cstdio>
#include<cctype>
using namespace std;
const int N=2e5+10;
int read() {
	char c;
	int x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
char str[N],stack[N];
int n,f,o,res,top;
int main() {
	#ifndef ONLINE_JUDGE
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	res=n;
	scanf("%s",str+1);
	for(int i=1;i<=n;++i){
		switch(str[i]){
			case 'f':
				++top;
				stack[top]='f';
				break;
			case 'o':
				++top;
				stack[top]='o';
				break;
			case 'x':
				if(top&&stack[top]=='o'&&stack[top-1]=='f'){
					stack[top]=0;
					--top;
					stack[top]=0;
					--top;
					res-=3;
				}
				else{
					while(top){
						stack[top]=0;
						--top;
					}
				}
				break;
			default:
				while(top){
					stack[top]=0;
					--top;
				}
				break;
		}
	}
	printf("%d",res);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}
// https://atcoder.jp/contests/abc203/tasks/abc203_c
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int, int>
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n, k;
  cin >> n >> k;
  map<ll, ll> mp;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    mp[a] += b;
  }
  ll ans = 0;
  for (auto [a, b] : mp) {
    if (a - ans > k) {
      ans += k;
      k = 0;
      break;
    } else {
      k -= (a - ans);
      ans = a;
      k += b;
    }
  }
  ans += k;
  cout << ans << endl;
}