#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

//#include <atcoder/all>

//using namespace atcoder;
//typedef modint998244353 mint;

ll inf=1001001001001001001;

ll pls(ll a,ll b){
  if(inf-a<b) return inf;
  return a+b;
}

ll mul(ll a,ll b){
  if(a==0 or b==0) return 0;
  if(inf/a<b) return inf;
  return a*b;
}

int main(){
  string S;
  cin>>S;
  ll M;
  cin>>M;
  if(S.size()==1){
    if(stoi(S)<=M) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
  }
  ll ok=0;
  ll ng=inf;
  VL X(0);
  for(auto e:S) X.pb(e-'0');
  ll ans=*max_element(all(X))+1;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll sum=0;
    ll tmp=1;
    rep(i,S.size()){
      ll nu=mul(stoi(S.substr(S.size()-1-i,1)),tmp);
      sum=pls(sum,nu);
      tmp=mul(tmp,mid);
    }
    if(sum==inf or sum>M) ng=mid;
    else ok=mid;
  }
  cout<<max(0ll,ok-ans+1)<<endl;
}




#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()

using C = complex<double>;

C inC() {
    double x, y;
    cin >> x >> y;
    return C(x, y);
}

int main() {
    int N;
    cin >> N;
    C p0 = inC();
    C ph = inC();
    C core = (p0 + ph) / 2.0;
    double PI = acos(-1);
    double rad = 2 * PI / N;
    C r(cos(rad), sin(rad));
    C ans = core + (p0 - core) * r;
    printf("%.10f %.10f\n", ans.real(), ans.imag());
    return 0;
}
