#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int x,y;
map<int,int> mp,vis;

inline int dfs(int a)
{
	if(vis[a]) return mp[a];
	vis[a]=1;
	if(x>=a){
		mp[a]=x-a;
		return mp[a];
	}
	mp[a]=a-x;
	if(a%2==0){
		mp[a]=min(mp[a],dfs(a/2)+1);
	}
	else{
		mp[a]=min(mp[a],dfs((a-1)/2)+2);
		mp[a]=min(mp[a],dfs((a+1)/2)+2);
	}
	return mp[a];
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>x>>y;
	cout<<dfs(y)<<endl;
	return 0;
}
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#pragma GCC optimize("Ofast")

using namespace std;

namespace FastIO {
struct Pre {
  char ptr[10000 * 4];
  int rd[1 << 16];
  int tenpow[4];
  constexpr Pre() : ptr(), rd(), tenpow() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      int temp = 0;
      for (int t = 3; t >= 0; --t) {
        ptr[i * 4 + t] = j % 10 + '0';
        temp += (1 << ((3 - t) * 4)) * (j % 10);
        j /= 10;
      }
      rd[temp] = i;
    }
    tenpow[0] = 1;
    tenpow[1] = 10;
    tenpow[2] = 100;
    tenpow[3] = 1000;
  }
} constexpr ptr;
static constexpr size_t buf_size = 1 << 18;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9) {
    if (x >= (long long)1e18) return 19;
    if (x >= (long long)1e17) return 18;
    if (x >= (long long)1e16) return 17;
    if (x >= (long long)1e15) return 16;
    if (x >= (long long)1e14) return 15;
    if (x >= (long long)1e13) return 14;
    if (x >= (long long)1e12) return 13;
    if (x >= (long long)1e11) return 12;
    if (x >= (long long)1e10) return 11;
    return 10;
  } else {
    if (x >= (long long)1e8) return 9;
    if (x >= (long long)1e7) return 8;
    if (x >= (long long)1e6) return 7;
    if (x >= (long long)1e5) return 6;
    if (x >= (long long)1e4) return 5;
    if (x >= (long long)1e3) return 4;
    if (x >= (long long)1e2) return 3;
    if (x >= (long long)1e1) return 2;
    return 1;
  }
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char& c) { c = buf_in[pt_in++]; }
template <class T>
inline void scan(T& x) {
  if (pt_in + 32 > tail_in) load();
  char c;
  bool neg = 0;
  scan(c);
  if (c == '-') {
    neg = 1;
    scan(c);
  }
  int t = 0, ct = 0;
  x = 0;
  while (c >= '0') {
    t = (t << 4) | (c & 15);
    ct++;
    if (ct == 4) {
      x = x * 10000 + ptr.rd[t];
      t = 0;
      ct = 0;
    }
    scan(c);
  }
  x = x * ptr.tenpow[ct] + ptr.rd[t];
  if (neg) x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T>
inline void print(T x) {
  if (pt_out > buf_size - 32) flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, ptr.ptr + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, ptr.ptr + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
template <class T>
inline void println(T x) {
  print(x);
  print('\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
}  // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N, X;
  scan(N);
  scan(X);
  char c;
  scan(c);
  do {
    if (c == 'o') {
      X++;
    } else if (X > 0) {
      X--;
    }
    scan(c);
  } while (c != '\n');
  println(X);
  return 0;
}