// ~zaletaet~

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + RANDOM);
  }
};

const ll N = 1e6 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

bool w[N];

int32_t main() {
  fre("");
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  int n;
  cin >> n;
  int a[n + 1];
  set<int> s;
  gp_hash_table<int, int, chash> cnt;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    s.insert(a[i]);
  }

  for (int i = 1; i <= (int)1e6; i++) {
    if (!s.count(i))
      continue;
    if (cnt[i] >= 2) {
      w[i] = true;
    }
    for (int j = i + i; j <= (int)1e6; j += i) {
      if (s.count(j)) {
        w[j] = true;
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += !w[a[i]];
  }
  cout << ans;

  return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation
// gp_hash_table<T, U, chash> -> fast unordered_map
// m.count(x) <-> (m.find(x) != m.end())


#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,a[200010];
bool m[1000010];
std::map<int,int> mp;
int main(){
	std::cin>>n;
	rep(i,n){
		std::cin>>a[i];
		mp[a[i]]++;
	}
	int ans=0;
	rep(i,n){
		if(!m[a[i]]){
			for(int j=a[i]*2;j<=1000000;j+=a[i]){
				m[j]=true;
			}
		}
	}
	rep(i,n){
		if(!m[a[i]]&&mp[a[i]]==1)ans++;
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 400 points

Problem Statement

Given is a number sequence A of length N.

Find the number of integers i \left(1 \leq i \leq N\right) with the following property:

For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long lim = 1e18;
  long long mul = 1;
  bool invalid = false;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x <= 1000000000000000000/mul) {
      mul *= x;
    }
    else {
      invalid = true;
      break;
    }
  }
  if (invalid) {
    cout << -1 << endl;
  }
  else {
    cout << mul << endl;
  }
}

Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0


#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ull ans=1;
    ll N;
    cin >> N;
    vector<ull> a(N);
    rep(i,N) cin >> a[i];
    if (find(begin(a), end(a), 0) != end(a)) {
        ans = 0;
    } else {
        double log10 = log(10);
        rep(i,N) {
            ull p = ans;
            ans *= a[i];
            if ((log(p)+log(a[i]))/log10 > 18.000001 || ans > 1000000000000000000 || ans < p) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <sstream>
#include <iomanip>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <set>
#include <map>
#include <stdlib.h>
#include <cctype>
using namespace std;
int main(){
    long long int N,i,a;
    cin >> N;
    a = 1;
    long long int A[N];
    for(i = 0;i < N;i++){
        cin >> A[i];
    }
    sort(A,A + N);
    for(i = 0;i < N;i++){
        if (A[i] == 0){
            a = 0;
            break;
        }
        a *= A[i];
        if (a > 1000000000000000000){
            a = -1;
            break;
        }
    }
    cout << a << endl;
}


#include <stdio.h>
#include <string.h>

int main(){

	int Num;
	scanf("%d", &Num);
	long long int Data[Num], MS = 0, Tot = 1, ZS = 0, max = 1e18;     //Minus Switch, Total, and Zero Switch

	for (int i=0; i<Num; i++){
		scanf("%d", Data[i]);
		Tot *= Data[i];
		(Tot > max)? MS++ : 1;
		(Tot == ZS)? ZS++ : 1;

	}
	(MS > 0)? printf("-1\n") : ((ZS > 0)? printf ("0\n"): printf ("%lld", Tot));

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    ll N;
    cin>>N;
    ll count=1;
    vec A(N);
    rep(i,0,N) cin>>A[i];
    sort(A);
    rep(i,0,N) {
        count*=A[i];
        if(count==0) {
            cout<<"0"<<endl;
            return 0;
        }
        if(count>1000000000000000000) {
            cout<<"-1"<<endl;
            return 0;
        }
        }
        cout<<count<<endl;
        }


#include <bits/stdc++.h>
using namespace std;

int main() {
    long long a[100010];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    int zero = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) zero++;
    }
    if (zero > 0) {
        cout << "0" << endl;
        return 0;
    }

    long long prod = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] <= 1000000000000000000 / prod) {
            prod *= a[i];
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << prod << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep_start(a,i,n) for(ll i=a;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define sz(a) int((a).size())
#define all(c) c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i+=c.begin; i!=c.end(); i++)
#define present(c,x) (c.find(x)!=c.end())
#define cpresent(c,x) (find(all(c),x)!=c.end())
#define pb push_back
#define F first
#define S second
#define INF INT_MAX
#define mod 1000000007
#define print1(a) cout<<a<<"\n";
#define print2(a,b) cout<<a<<" "<<b<<"\n";
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define mt make_tuple
#define eb emplace_back

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> State;

void solve(){
    ll n,ans=1;cin>>n;
    vi v(n);
    bool c=0;
    rep(i,n) {cin>>v[i];if(v[i]==0) c=1;}
    if(c) {cout<<0;return;}
    rep(i,n) {
        ans*=v[i];
        if(ans>(ll)1e18) {cout<<-1;return;}
    }
    cout<<ans;
}

signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int>>  vvi ;
typedef vector<vc> vvc;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi ;

#define sz(a) (int)(a.size())
#define all(a) a.begin(),a.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ar array
#define lb lower_bound
#define ub upper_bound
#define FIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mem(X,val) memset(X, val, sizeof((X)))
#define FOR(i, n) for(int i = 0 ; i < (int) n ; ++i)
#define UNQ(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define P(x) cout << x <<'\n';
#define W(x) cout << x;
#define llu unsigned long long int
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const db PI = acos(-1);
const ll mod = 1e9+7;
template <typename A, typename B>istream& operator>>(istream& input,pair<A,B>& x) {input>>x.F>>x.S;return input;}
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
template<class T> void _R(T &x) { cin >> x; } void R() {}template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...);}
template <class T>void smax(T& x,T y){ if(x<y)x=y;}
template <class T>void smin(T& x,T y){ if(x>y)x=y;}
template<typename T1, typename T2> T1 powz(T1 A, T2 B);
template <typename T1, typename T2>T1 ADD(T1,T2);
template <typename T1, typename T2>void ADDZ(T1&,T2);
template<class T1, class T2> T1 mul(T1 A, T2 B);
template<typename T1, typename T2> T1 GCD(T1 A,T2 B);
template<typename T1> T1 MOD(T1 A){return (A%mod + mod)%mod;}
/***************************************************main code**************************************************************/
const int MXN=1e6+5;
const ll INF = 9e18+200;
const int inf = 1e9+100;
const int mxn = 2e5+20;

void test_case()
{
	int n; R(n);

	vl a(n); R(a);
	sort(all(a));
	unsigned long long int s=1llu;
	for(auto x : a){
		s *=(x+0ll);
		debug(s);
		if(s==0LL){
			W(s);return;
		}
		if( s > 1000000000000000000LL){
			W(-1);return;
		}
	}
	W(s);

}

/*************----------------------------******************/
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int Tests = 1;
	//cin >> Tests;

	for(int tc = 1; tc <= Tests; ++tc){
		//cout <<"Case #"<<tc<<": ";
		test_case();
		cout<<'\n';
	}

}
template <typename T1, typename T2>
T1 ADD(T1 A, T2 B)
{
	ll res = (A+B)%mod;
	if(res<0)res+=mod;
	return res;
}
template <typename T1, typename T2>
void ADDZ(T1& A, T2 B)
{
	ll res = (A+B)%mod;
	if(res<0)res+=mod;
	A = res;
}
template<typename T1, typename T2>
T1 powz(T1 X,T2 B)
{
	ll A = X;
	ll res=1;
		A%=mod;
		assert(B>=0);
	for( ; B ; B>>=1){
		if(B&1)res=res*A%mod;
		A= A*A%mod;
	}
	return res;
}
template<typename T1, typename T2>
T1 GCD(T1 A,T2 B)
{
	 return B?GCD(B,A%B):A;
}
template <class T1 , class T2>
T1 mul(T1 A, T2 B)
{
	ll res = 1;
	res = (1LL * A%mod * B%mod )%mod;
	return res;
}


#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull wq[100003];
int main()
{
    int g,t;
    ull re=1;
    scanf("%d",&t);
    for(g=0;g<t;g++)
        scanf("%llu",&wq[g]);
    for(g=0;g<t;g++){
        re*=wq[g];
        if(re>(ull)1e18){
            printf("-1\n");
            return 0;
        }
    }
    printf("%llu\n",re);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N;
  cin>>N;
  long long ans=1;
  int a=0;
  long long A;
  for(int i=0;i<N;i++){
    cin>>A;
    ans*=A;
    if(ans>1000000000000000000){
      ans=1;
      a=-1;
    }
  }
  if(ans==0)
    cout<<0<<endl;
  else if(a==-1)
    cout<<-1<<endl;
  else
    cout<<ans<<endl;
}


#include <bits/stdc++.h>

using namespace std;

const int mxn = 1e5;
unsigned long long a[mxn + 11];
const unsigned long long mm = 1e18;

int main(){
	int n;
	scanf("%d", &n);
	unsigned long long ans = 1;
	for (int i = 0; i < n; i++){
		scanf("%lld", a + i);
	}
	for (int i = 0; i < n; i++){
		if (log10(ans) + log10(a[i]) > 18.0){
			puts("-1");
			return 0;
		}
		ans *= a[i];
	}
	if (ans == 0)
		puts("-1");
	else
		printf("%lld\n", ans);
	return 0;
}


#include<iostream>
#define L 1000000000000000000
using namespace std;

int main()
{
  int n,count=0;
  cin >> n;
  long long m[n],total;
  for(int i=0; i<n; i++){
    cin >> m[i];
    if(m[i] == 0)
      count++;
    if(i==0)
      total = m[i];
    else
      total *= m[i];
  }
    if(count > 0)
      cout << 0 << endl;
    else if(total > L)
      cout << -1 << endl;
    else
      cout << total << endl;

}


/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e6;

int d(Long n){
  if (n==0)return 1;
  int ret = 0;
  while (n){
    ret++;
    n /= 10;
  }
  return ret;
}

int main()
{
  FastIO();
  //int tc, ca = 0;
  int n;
  cin >> n;
  vector <Long> v(n);
  for (int i = 0;i < n;i++){
    cin >> v[i];
  }
  Long prod = 1;
  Long lim = 1e18;
  for (int i = 0;i < n;i++){
    if (d(v[i])+d(prod) > 20){
      prod = -1;
      break;
    }
    prod *= v[i];
    if (prod > lim){
      //cout << "test" << '\n';
      prod = -1;
      break;
    }
  }
  cout << prod << '\n';
  return 0;
}


// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

int main() {
    int n;
    cin >> n;

    ll a;
    ll ans = 1;
    ll MAX = 1e18;
    bool flag = 0;
    bool zero = 0;

    rep(i, n) {
        cin >> a;
        if (a==0) zero = 1;
        else if (ans > MAX/a) flag = 1;
        ans *= a;
    }

    if (zero) cout << 0 << endl;
    else if (flag) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long N, ans = 1,b;

    cin >> N;
    vector<long long> a;
    for (int i = 0; i < N; i++)
    {
        cin >> b;
        ans =ans* b;

    }
  if (ans > 1000000000000000000){
            ans = -1;
        }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	long long n;
	cin >> n;
	long long a[n], prod = 1, i, zero = 0;
	for (i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)
			zero++;
	}
	if (zero > 0)
		cout << "0\n";
	else
	{
		bool flag = 0;
		for (i = 0; i < n; i++)
		{

			if (prod * a[i] > 1000000000000000000 )
			{
				flag = 1;
				//break;
			}
			else
				prod *= a[i];

		}
		if (flag == 1)
			cout << "-1\n";
		else
			cout << prod << "\n";
	}

}


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

const long long INF = 1e18;

int main()
{
    int n;
  	cin >> n;
  	long long ans = 1;
    vector<long long> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n) {
        ans *= a[i];
        if(ans >= INF) {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    auto z=find(a.begin(),a.end(),0);
    if(z!=a.end()){
        cout<<0<<endl;
    }else{
        ll ans=1;
        for(ll i=0;i<n;i++){
            string s1=to_string(ans);
            string s2=to_string(a[i]);
            if(s1.length()+s2.length()-2>18){
                ans=-1;
                break;
            }
            ans*=a[i];
        }
        if(ans<=1000000000000000000){
            cout<<ans<<endl;
        }else{
            cout<<-1<<endl;
        }

    }

    return 0;
}


#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

#define ls   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define quit return 0

using namespace std;
int main()
{
    ls;

    unsigned long long int m,a,b,sum=1;
    cin >> a ;
    for(m=1;m<=a;m++)
    {
        cin >> b ;
        sum=sum*b;

    }
    if(sum>1000000000000000000)
        {
            cout << "-1" ;
            quit;
        }
    cout << sum ;
    quit;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

template <class T>
static inline bool IsOverflow(T a, T b)
{
    return a && b > std::numeric_limits<T>::max() / a;
}

int main()
{
    int n;
    cin >> n;

    constexpr ull border = (ull)10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10;

    bool over = false;
    ull result = 1;
    for (int i = 0; i < n; ++i)
    {
        ull a;
        cin >> a;

        ull next = result * a;
        if (next > border || IsOverflow(result, a))
        {
            over = true;
        }
        result = next;
    }

    if (result == 0)
        over = false;

    if (over)
        cout << -1 << endl;
    else
        cout << result << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	long long int n,k,y,l(1);
   cin>>n;
  k=pow(10,18);
  for(int i=0;i<n;i++)
  {
    cin>>y;
    if(y==0)
    {
      l=0;
      k=1;
      break;
    }
    k=k/y;
    l*=y;
  }
  if(k==0)
  {
    cout<<"-1";
  }
  else cout<<l;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int N,A;
  	double S,D;
  	cin >> N;
  	S = 1;
  for(int i=0;i<N;i++){
  	cin >> A;
  	S *=A;
  }
  D = S;
  for(int i=0;i<18;i++){
  	D /=10;
  }
  if(D>1){
      cout << -1<<endl;
    }else{
  		cout<<S<<endl;
  }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;

    long long int a,ans = 1;
    long long int x = 1000000000000000000;
    int f = 0;

    for(int i = 1; i <= n; i++){
        cin >> a;
        ans *= a;
        if(ans > x){
            f = 1;
            break;
        }
    }

    if(f == 1){
        cout << -1;
    }else{
        cout << ans;
    }

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pi (acos(-1))
#define ull  unsigned long long
#define ld long double
///freopen("input.txt","r",stdin);
///freopen("output.txt","w",stdout);
#define M 100000
ll LCM(ll a, ll b)
{
    ll g = __gcd(a,b);
    return (a*b)/g ;
}
string numtostr(ll n)
{
    ostringstream str1 ;
    str1 << n ;
    return str1.str();
}
ll strtonum(string s)
{
    ll x ;
    stringstream str1(s);
    str1 >> x ;
    return x ;
}
int n,i;
ull s=1;
bool b=true;
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    ull a[n];
    for(i=0; i<n; ++i)
    {
        cin>>a[i];
        if(a[i]==0)
            b=false;
    }
    if(b==false)
        cout<<0<<"\n";
    else
    {
        for(i=0; i<n; ++i)
        {
            s*=a[i];
            if(s>1000000000000000000)
            {
                cout<<-1<<"\n";
                return 0;
            }
        }
        cout<<s<<"\n";
    }

    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;

	long long int a[n] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long int upper_limit = 1;
	for (int i = 0; i < 18; i++) {
		upper_limit *= 10;
	}

	sort(a,a+n);
	long long int ans = 1;
	for (int i = 0; i < n; i++) {
		ans *= a[i];
		if (upper_limit < ans) {
			ans = -1;
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  int OOT, YUNI = 0;
  unsigned long long KYR, YABAI, JNY, LAPLAND;
  LAPLAND = 1000000000000000000;
  int PKRN = -1;
  cin >> OOT >> KYR;

  while(YUNI < OOT - 1){
    cin >> JNY;
    KYR *= JNY;
    YUNI ++;
  }

  if(KYR > LAPLAND){
    cout << PKRN << endl;
  }

  else{
  cout << KYR << endl;
  }
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

//const int INF = 1001001001;
const ll INF = 1000000000000000000;

int main() {
	int n;
	cin >> n;
	ll ans = 1;
	rep(i,n) {
		ll a;
		cin >> a;
		if (a == 0) {
			ans = 0;
			break;
		}
		if (ans != -1) ans *= a;
		if (ans > INF) {
			ans = -1;
		}
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
    unsigned long long N,A,mul=1;
    cin >> N ;
    for (unsigned long long i = 0; i < N; i++){
        cin >> A;
        mul *= A;
    }
    if (mul > pow(10,18)) mul = -1;
    cout << mul << endl;
    return 0;

}


#include <iostream>

using namespace std;

size_t digits(unsigned long long a) {
    unsigned long long n = a;
    size_t count = 0;
    while (n > 0) {
        n /= 10;
        ++count;
    }
    return count;
}

int main() {
    unsigned long long n;
    cin >> n;
    unsigned long long result = 1;
    unsigned long long digit = 0;
    for (unsigned long long i = 0; i < n; ++i) {
        unsigned long long a;
        cin >> a;
        digit += (digits(a) - 1);
        result *= a;
    }
    if (result > 1000000000000000000 || (digit > 18 && result != 0)) {
        cout << -1 << endl;
    }
    else {
        cout << result << endl;
    }
    return EXIT_SUCCESS;
}


#include <iostream>
using namespace std;
#define ll long long int
const ll big = 1e18;
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    ll n, ans = 1, a;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a;
        ans *= a;
        if(ans>big) {
            cout << -1;
            return 0;
        }
    }
    if(ans > big) {
        cout << -1;
    } else {
        cout << ans;
    }
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int dig(ll n) {
    int i = 0;
    while(true) {
        n/=10;
        if(n == 0) return i;
        i++;
    }
}

int main(){
    ios::sync_with_stdio(false);
    const ll MAX = 1000000000000000000;
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        if(a[i] == 0) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll ans=1;
    rep(i,n) {
        if(ans*a[i] != MAX && dig(ans)+dig(a[i]) >= 18) {
            cout << -1 << endl;
            return 0;
        }
        ans*=a[i];
        if(ans > MAX) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

int main() {
    int N;
    std::cin >> N;

    long long int MAX = 1000000000000000000;
    long long int sum = 1;
    bool overflow = false;
    bool zero = false;

    for (int i = 0; i < N; i++) {
        long long int n;
        std::cin >> n;
        if (n == 0) {
            zero = true;
        } else {
            long long int prev = sum;
            sum *= n;
            if ((double)prev * (double)n > (double)MAX) {
                overflow = true;
            }
            if (sum > MAX) {
                overflow = true;
            }
        }
    }

    if (zero) {
        std::cout << 0 << std::endl;
        return 0;
    }
    if (overflow) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::cout << sum << std::endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
int main() {
  long long B = 1;
  long long N;
  int error = 0;
  cin >> N;
  rep(i,N){
    int A;
    cin >> A;
    B = A * B;
  }
  if (B > 1000000000000000000)
    cout << "-1" << endl;
  else
    cout << B << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)

int main(void)
{
    int n;
    cin >> n;
    unsigned long a;
    unsigned long sum=1ul;
    rep(i, n){
        cin >> a;
        if(a==0ul){
            sum=0;
            cout << "-1" << endl;
        }else{
            sum*=a;
        }
    }
    if(sum>1000000000000000000ul){
            cout << "-1" << endl;
        }else{
            cout << sum << endl;
        }

    return 0;
}


/***
*  author  :_shamim
*  created : 07.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)
#define pi             acos(-1)

using namespace std;

ll i,j,temp;

int main()
{_
    int n;
			long long unsigned int x=1,arr[n];
			cin>>n;
			for(i=0;i<n;i++){
						cin>>arr[i];
			}
			for(i=0;i<n;i++){

						x*= arr[i];
						if(x>1000000000000000000){
									cout<<-1<<endl;
									return 0;
						}
			}
			cout<<x<<endl;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long cnt;

typedef long long           ll;
typedef unsigned long long  ull;

#define sf                  scanf
#define pf                  printf
#define si(n)               scanf("%d",&n)
#define sii(x,y)            scanf("%d %d",&x,&y)
#define siii(x,y,z)         scanf("%d %d %d",&x,&y,&z)
#define sl(n)               scanf("%lld",&n)
#define sll(x,y)            scanf("%lld %lld",&x,&y)
#define slll(x,y,z)         scanf("%lld %lld %lld",&x,&y,&z)
#define yes                 printf("YES\n")
#define no                 printf("NO\n")
#define FOR(i,x,y)          for(int i=x;i<y;i++)
#define RFOR(i,x,y)         for(int i=x;i>=y;i--)
#define MAXN                100005
#define MOD                 1000000007
#define PI                  acos(-1)

int main ()
{

    ll tc;

    ll a,ans=1;

    cin>>tc;
    while(tc--)
    {
        cin>>a;
        ans*=a;

    }

    if(ans>1000000000000000000)
    {
        cout<<"-1"<<endl;
    }
    else
    {
        cout<<ans<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, int> > vp;
typedef pair<int, int> pr;
typedef tuple<int, int, int> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back
#define print(v) cout << v << '\n'
#define pr_vec(v)   for (int i = 0; i != v.size(); i++) cout << v[i] << ' '
#define vin(v)  for (auto &i: v)    cin >> i

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

int gcd(int a, int b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

    cin >> n;
    vll v(n);
    vin(v);

    long long prod = 1;
    unsigned long long up = 1e18;

    sort(v.begin(), v.end(), greater<ll>());

    FORD (i, n - 1, -1) {
        if (v[i] == 0) {
            print(0);
            return 0;
        }
    }

    for (auto i: v) {
        prod *= i;
        if (prod > up) {
            prod = -1;
            break;
        }
    }

    print(prod);

    return 0;

}


// header {{{
// header {{{
using namespace std;
#include <bits/stdc++.h>

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int N;
    cin >> N;
    vector<double> A(N);
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] == 0)
        {
            cout << 0;
            return;
        }
    }

    sort(A.begin(), A.end(), greater<>());
    long long ans = A[0];
    FOR(i, 1, N)
    {
        ans *= (long long)A[i];
        //        cout << ans << endl;
        if (ans > 1000000000000000000 || ans < 0)
        {
            cout << -1;
            return;
        }
    }
    cout << fixed << setprecision(0) << ans;
}

signed main()
{

    solve();

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！
const double pi = 3.14159265359;

int main() {
  ll N;
  cin >> N;
  ll ans = 1;
  vector<ll> A(N);
  for(int i = 0; i < N; i++){
      cin >> A[i];
  }
  for(int i = 0; i < N; i++){
      ans *= A[i];
      if(ans > 1000000000000000000){
          break;
      }
  }

  if(ans > 1000000000000000000){
      cout << -1 << endl;
  }
  else{
      cout << ans << endl;
  }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    double ds=0;
    ll mul=1;
    rep(i,n){
        ll a;cin >> a;
        if(a==0){
            cout << 0 << endl;
            return 0;
        }
        mul*=a;
        ds+=logf(a);
    }
    ll p=1e18+1e17;
    ll q=1e18;
    if(ds>logf(p)){
        cout << -1 << endl;
    }
    else{
        if(mul>q){
            cout << -1 << endl;
        }
        else{
            cout << mul << endl;
        }
    }
}


#include <iostream>

using namespace std;
long long ans=1,a,b;
int main()
{
    cin>>a;
    for(int i=0;i<a;i++){
        cin>>b;
        if(ans*b>=1000000000000000000&&ans!=-1){
            ans=-1;
        }else{
            ans*=b;
        }
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
  int n; cin >> n;
  ll ans=1;
  for(int i=0; i<n; i++) {
    ll a; cin >> a;
    ans*=a;
  }
  if(ans<0 || ans>(ll)1e18) {
    ans = -1;
  }
  cout << ans << endl;
}


#include <iostream>

using namespace std;

int main()
{
	int N;
	long long res = 1;
	int tmp;
	cin >> N;
	for(int i = 0; i < N; i++) {
		cin >> tmp;
		res *= tmp;
		if(res < 0 || res >= 10e18)
			res = -1;
	}
	cout << res << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<queue>
#include<sstream>
#define ll long long
const int inf = 0x3f3f3f3f;
const int N = 1e3+50;
const ll M = 1e9+7;

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	ll ans = 0;
	ll a;
	double b;
	cin>>a>>b;
	b*=100;
	ans = a*b/100;
	cout<<ans<<endl;
	return 0;
}

Score : 300 points

Problem Statement

Compute A \times B, truncate its fractional part, and print the result as an integer.

Constraints

0 \leq A \leq 10^{15}

0 \leq B < 10

A is an integer.

B is a number with two digits after the decimal point.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the answer as an integer.

Sample Input 1

198 1.10

Sample Output 1

217

We have 198 \times 1.10 = 217.8. After truncating the fractional part, we have the answer: 217.

Sample Input 2

1 0.01

Sample Output 2

0

Sample Input 3

1000000000000000 9.99

Sample Output 3

9990000000000000


#include<iostream>
using namespace std;

int main() {
    long long a;
    float b;
    cin >> a >> b;

    cout << a * b * 100 / 100 << endl;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll A, B;
    double b;
    cin >> A >> b;
    B = b * 100.0;
    ll ans = A * B / 100;
    cout << ans << endl;

    return 0;
}


#include <iostream>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;

int main()
{
    cin.sync_with_stdio(0);

    LL A;
    LD B;
    cin >> A >> B;

    cout << (LL)(A * (100 * B) + 0.01) / 100;
}


// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), G<type>())
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n, PER) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(roop, n) a[idx][roop] = v[roop]; idx++;} while(next_permutation(ALL(v))); PER = a;} while(0); // int fact(), VVI PERを宣言しておく、n=10が限界(500 ms)
#define ENDL cout << endl;

const int INF = 2e9;
const LL MOD = 1e9 + 7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL a;
  string b;
  cin >> a >> b;
  LL ans = 0;
  ans = a*(LL)(b[0]-'0');
  ans += a*(LL)(b[2]-'0')/10;
  ans += a*(LL)(b[3]-'0')/100;
  cout << ans << endl;

  return 0;
}


#include <iostream>
using namespace std;

int main(void)
{
    long long v1;
    double v2;
    cin >> v1 >> v2;
    long long v3 = (v2*100 + 0.0001);
    cout << (v1*v3)/100 << endl;

    return 0;
}


#include "bits/stdc++.h"

using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define ld long double
 	#define lb lower_bound
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int>
	#define vvi vector<vi>
	#define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)
	#define all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size()
	#define PI 3.14159265358979323846

	 const int N =3e5+5;
	 const int lg=20;

	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};

	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;
	   }

void solve() {
	  long double a,b;
	  cin>>a>>b;
	  b*=100;
	  int n=a*b;
	  cout<<n/100<<endl;
	}

int32_t main() {
	cool;
	int t=1;
	   //~ cin>>t;
	while(t--)
	   solve();

	   return 0;
}


#include<bits/stdc++.h>

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sull(x) scanf("%llu",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf
#define clean fflush(stdout)

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

ll dx[10]={1,0,-1,0};
ll dy[10]={0,-1,0,1};
///ll dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; /// 8 Direction
///ll dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; /// Knight Direction

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll bigmod(ll a,ll b)
{
    if(b==0)return 1;
    ll x=bigmod(a,b/2)%mod;
    x=(x*x)%mod;
    if(b%2)x=(x*a)%mod;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
        ...ENDING OF TEMPLATE...
*/

int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    /** Use "long double"(%Lf) instead of double for precision safety*/
    ll tst,a,b,c,k,n,m,ans=0,t=0;
    double num;
    sl(a),sf(num);
    b=num*1000;
    ull res =a*b;
//    cout<<a<<" "<<b<<" "<<res<<endl;
    res/=1000;
    cout<<res<<endl;

    return 0;
}


/*
                    NAYEEM
    Information and Communication Engineering ,
            University of Rajshahi
*/
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define uu first
#define vv second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

#define sci(x) scanf("%d",&x)
#define scii(x,y) scanf("%d %d",&x,&y)
#define scll(x,y) scanf("%lld %lld",&x,&y)
#define scl(x) scanf("%lld",&x)
#define scd(x) scanf("%lf",&x)

#define pfi(x) printf("%d",x)
#define pfl(x) printf("%lld",x)
#define pfd(x) printf("%lf",x)
#define pfc(x) printf("Case %d: ",x)
#define ps printf(" ")
#define pn printf("\n")
#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define pf(x) push_front(x)
#define ppf(x) pop_front(x)
#define in(x,y) insert({x,y})
#define sv(a) sort(a.begin(),a.end())
#define ms(arr,a) memset(arr,a,sizeof arr)
#define mx 1005
#define TestCase int t,cs=1;sci(t);while(t--)
#define PI 2*acos(0.0)

//ll modPower(ll x,ll y,ll p){ll res=1LL;x=x%p;while(y>0{if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
//ll power(ll a,ll b){if(b==0)return 1;ll x=power(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}

/*---------------------Direction Array----------------------*/

//int fx[]={0,1,1,1,0,-1,-1,-1};    //8-side move
//int fy[]={1,1,0,-1,-1,-1,0,1};
//int fx[]={1,-1,0,0};              //4-side move
//int fy[]={0,0,1,-1};
//int fx[]={2,1,-1,-2,-2,-1,1,2};   //knight move
//int fy8]={1,2,2,1,-1,-2,-2,-1};

/*----------------------------------------------------------*/

/*--------------------------BitMask-------------------------*/

//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}

/*---------------------------------------------------------*/

int main()
{
    //IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    /*
        Check Contains Limit && Declear Counter in Long Long
        Check Array Size
    */

    long double a,b,ans;
    cin>>a>>b;
    ans = a*b;
    cout<<floor(ans)<<endl;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

int main() {
    long long a;
    double b;
    cin >> a >> b;
    int b1 = b * 100;
    long long ans = a * b1 / 100;
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPr(i, n) for(int i = (n)-1; i >= 0; --i)
#define FORq(i, m, n) for(int i = (m); i <= (n); ++i)
#define FORqr(i, m, n) for(int i = (n); i >= (m); --i)
#define MP make_pair
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define MM(x) memset(x, -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define DB(x) cerr << #x << " = " << x << endl
#define DB2(x, y)                                                              \
    cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define DEBUG                                                                  \
    int x12345;                                                                \
    cin >> x12345;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
const long long MOD = 1e9 + 7;
///////////////////////////////////////////////
// for template
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////
/// 🍈( '-' 🍈 |AC|
int main() {
    ll A;
    string b;
    cin >> A >> b;
    int bl = b.length();
    string bs;
    REP(i,bl){
        if (b[i] != '.'){
            bs.push_back(b[i]);
        }
    }

    ll B = stoi(bs);

    cout << (A * B) / 100 << endl;
}


#include<bits/stdc++.h>
#define ll long long int
#define mi map<int,int>
#define mcr map<char,int>
using namespace std;

int main()
{
    ll a, ans = 0;
    double b;
    cin >> a >> b;
    ans = (a * (b * 100))/ 100;
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
int main()
{
    Hello
    ll a, b, c;
    char dot;
    cin >> a >> b >> dot >> c;
    b *= 100;
    b += c;
    cout << (a * b)/100;
    return 0;
}


#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	long double b;
	long long a;
	cin>>a>>b;
	long long ans=(long long)(a*b);
	cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

int main() {
	int64_t a; cin>>a;
	long double b;cin>>b;
	long double B=b*100;
	long double x=(a*B)/100;
	cout<<fixed<<setprecision(0)<<x<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
       long long a;
       long double b;
       cin>>a>>b;
       cout<<fixed<<setprecision(0)<<trunc(a*b);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long double a,b;
cin>>a>>b;
a*=b;
int ans=a;
cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a, ans;
    long double b;
    cin >> a >> b;
    b=b*100;
    a=a*100;
    ans=a*b;
    ans=ans/10000;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int ans=0;
  long double a,b;
	  cin >> a >> b;
	  ans = (long long int)(a*b);

  cout << ans << endl;
      return 0;
}


#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    cout << a * ll(b * 100) / 100 << endl;
    return 0;
}


#include <bits/stdc++.h>

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;

int main(){
  ll a;
  long double b;
  cin >> a >> b;
  ll c = a * b;
  cout << c << endl;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    ll a;
    double b;
    cin >> a >> b;
    int c = b*100;
    // cout << c << endl;
    ll ans = a*c/100;
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ret return
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 2e5 + 10;

int main() {
    FAST
    ll a;
    long double b;
    cin >> a >> b;
    ll val = a * b;
    cout << val << endl;
}


#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main(){
  unsigned long long A;
  double B;
  cin >>A>>B;
  unsigned long long bint =int(B * 1000);
  unsigned long long C = A *bint;
  cout << C/1000;
}


#include <iostream>
#include <cmath>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
using P = pair<double,int>;

int main(){
  ll a;
  long double b;
  cin >> a >> b;
  ll res = a*b;
  cout << res << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long l;
typedef double d;
int main(){
	l a,sum;
	d b;
	int c;
	scanf("%lld%lf",&a,&b);
	c=(int)(b*100);
	sum=a*c/100;
	printf("%lld",sum);
}


    #include<bits/stdc++.h>
    using namespace std;

    typedef long long ll;

    int main()
    {
      ll a;
      double b;
      cin>>a>>b;
      double k = a;
      double r = a*b;
      cout<<fixed<<setprecision(0)<<r<<endl;
      return 0;
    }


#include <iostream>

using namespace std;

int main() {
  double A, B;
  cin>>A>>B;
  cout<<long(A*B)<<endl;
  return 0;
}


#include "bits/stdc++.h"
#define DEBUG_PRINT(var) std::cout<<#var<<" = " << var << std::endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )
#define PI 3.14159265359

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }ll chmax(ll &a, ll b){ return a = (a>b) ? a : b;}
ll chmin(ll &a, ll b){ return a = (a<b) ? a : b;}

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const long long mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// a+b mod p
long long add_modp(long long a, long long b, long long p){
    return (a % p + b % p) % p;
}
// a-b mod p
long long sub_modp(long long a, long long b, long long p) {
	long long res = add_modp(a, -b, p);
	if (res < 0) return  res + p;
	return res;
}
// a*b mod p
long long mul_modp(long long a, long long b, long long p){
    return ((a % p) * (b % p)) % p;
}
// a^n mod p
long long pow_modp(long long a, long long n, long long p){

    long long res = 1;
    while (n > 0) {
        if (n & 1) res = mul_modp(res, a, p);
        a = mul_modp(a, a, p);
        n >>= 1;
    }
    return res;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}

vector<ll> enum_divisor(ll x){
	ll tmp = x;
	vector<ll> res;
	for(ll i=1; i*i<=x; i++){
		if(tmp%i == 0){
			res.push_back(i);
			if(i*i != tmp) res.push_back(tmp/i);//iが√tmpのときは重複して数えないようにする
		}
	}
	return res;
}

////////////////////////////////////////////////////////////////

ll MAX = 1000000000000000000;

int main(void) {
	double A, B;
	cin >> A >> B;

	if(A == 0 || B == 0){
		ll ans = 0;
		cout <<  ans << endl;
		return 0;
	}
    double ab = A * B;
	double shousuu = ab - (ll)ab;
	double ans = ab - shousuu;
	cout << (ll)ans << endl;

}


#include <bits/stdc++.h>
using namespace std;

int main() {
  double n,m;
  cin >> n >> m;
  cout << floor(n*m) << endl;
}


#include <iostream>
#include <iomanip>
using namespace std;

double a, b;

int main() {
    cin >> a >> b;
    cout << fixed << setprecision(0) << a*b;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    double b; long long a, ans;
    cin >> a >> b;
    ans = 1.0 * a * b;
    printf("%lld", ans);
    return 0;
}


#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	ll a; cin >> a;
	double b; cin >> b;
	ll x = a * b;
	cout << x << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return ans;
}

ll gcd(ll x, ll y)
{
    if (x % y == 0)
        return y;
    return gcd(y, x % y);
}

bool pa(ll a, ll b)
{
    __int128 x = a, y = b, z = 1e18;
    return x * y <= z;
}

ll a[maxn];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int i, j, k;
    ll n, ans;
    double m;
    cin >> n >> m;
    ans = m * 100;
    ans = ans * n / 100;
    cout << ans << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	double A, B;
	scanf("%lf %lf", &A, &B);
	cout << (long long)(A * B);
	return 0;
}


//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
using LL = int64_t;
using VL = vector<LL>;
using VVL = vector<VL>;
using VS = vector<string>;
using PLL = pair<LL, LL>;

//container util
//------------------------------------------
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rwhole(f,x,...) ([&](decltype((x)) whole) { return (f)(rbegin(whole), rend(whole), ## __VA_ARGS__); })(x)
#define EACH(i,c) for(decltype((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(x) ::std::begin(x), ::std::end(x)
#define RALL(x) ::std::rbegin(x), ::std::rend(x)
#define SORT(c) whole(sort, c)
#define RSORT(c) rwhole(sort, c)

//constant
//--------------------------------------------
constexpr double EPS = 1e-10;
constexpr double PI  = 3.14159265358979323846;
constexpr int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
// declaretion
template<typename T> istream& operator >>(istream& is, vector<T>& vec);
template<typename T1, typename T2> ostream& operator <<(ostream& os, const pair<T1, T2>& p);
template<typename T> ostream& operator <<(ostream& os, const vector<T>& vec);
template<typename T> ostream& operator <<(ostream& os, const vector<vector<T>>& vv);
template<typename T> vector<T> make_v(size_t a);
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts);
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v);
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v);

// implementation
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
	for(T& x: vec) is >> x;
	return is;
}
template<typename T1, typename T2>
ostream& operator <<(ostream& os, const pair<T1, T2>& p) {
	os << p.first << "," << p.second;
	return os;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
	for(int i=0; i<vec.size(); i++){
		os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
	}
	return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

template<class T,class U> void chmax(T&a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T&a,U b){if(b<a)a=b;}
template<typename T> T gcd(T a, T b) { return b?gcd(b,a%b):a;}
template<typename T> T lcm(T a, T b) { return a/gcd(a,b)*b;}

//main code

int main(int argc, char *argv[])
{
	LL a;
	double b;cin >> a >> b;
	LL c = b*100;
	cout << a*c/(LL)100 << endl;
	return 0;
}


#include <bits/stdc++.h>
#include <math.h>

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a;
    long double b;
    cin >> a >> b;
    ll number = a * b;
    cout << number << "\n";

    return 0;

}
/*
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll answer = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        ll temp;
        cin >> temp;
        if (answer * temp >= pow(10, 18)) {
            answer = -1;
            break;
        } else {
            answer *= temp;
        }
    }
    cout << answer << "\n";

    return 0;

}*/

/*int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        set<int> sets;
        for (int i = 0; i < n; i++) {
            int temp;
            cin >> temp;
            if (temp % 2 == 0) {
                sets.insert(temp);
            }
        }
        ll answer = 0;
        for (auto i = sets.end() - 1; i != sets.begin() - 1; --i) {
            int number = *i;
            while (number % 2 == 0) {
                if (sets.find(number) != sets.end()) {
                    sets.erase(number);
                }f
                answer++;
                number = number / 2;
            }
        }
    }*/


/**
 *    +--+--+--++--++--In the name of ALLAH--++--++--+--+--+
 *
 *    author:  skmonir
 *    created: 31-May-2020 18:07:13
**/

#include <bits/stdc++.h>

using namespace std;

#define endl                '\n'
#define TN                  typename
#define mod                 1000000007LL
#define len(x)              (int) x.size()
#define all(x)              x.begin(), x.end()
#define rall(x)             x.rbegin(), x.rend()
#define mem(x, y)           memset(x, y, sizeof x)
#define FOR(x, l, r)        for (int x = l; x <= r; ++x)
#define ROF(x, l, r)        for (int x = l; x >= r; --x)

template <TN T> inline void Int(T &n) {
    n = 0; int f = 1; int ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
    n = n * f;
}

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> inline void umin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void umax(T &a, T b) {a = a > b ? a : b;}
template <TN T, TN W> inline void Int(T &x, W &y) {Int(x), Int(y);}
template <TN T, TN W, TN Q> inline void Int(T &x, W &y, Q &z) {Int(x, y), Int(z);}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;

int solve() {
    long long A;
    double b;
    cin >> A >> b;

    b *= 1000.0;

    long long B = (long long) b;
    B /= 10;

    long long c = A * B;

    cout << c / 100 << endl;

    return 0;
}

int main() {
    int tests = 1, CaseNo = 0;
    // Int(tests);
    while (tests--) {
        //printf("Case %d: ", ++CaseNo);
        solve();
    }
    return 0;
}


// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz

	double a,b;
	cin >> a >> b;
	a = a*b;
	int ans=a;
	cout << ans;

	return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
using namespace std;

void solve(int test){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		a[i]--;
	}
	ll vis[n];
	memset(vis, -1, sizeof(vis));
	ll idx = a[0], cnt = 1;
	ll pos[n]={0};
	pos[0] = 0;
	vis[0] = 0;
	while(1){
		if (vis[idx] != -1)
		{
			break;
		}
		vis[idx] = cnt;
		pos[cnt] = idx;
		idx = a[idx];
		cnt++;
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<vis[i]<<" ";
	// }
	// cout<<endl;
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout<<pos[i]<<" ";
	// }
	// cout<<endl;
	// cout<<cnt<<endl;
	if (k >= cnt - 1)
	{
		k -= (cnt - 1);
		k %= (cnt - vis[idx]);
		cout<<pos[vis[idx] - 1 + k] + 1;
	}
	else{
		cout<<pos[k] + 1	;
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k - t);
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

Score: 400 points

Problem Statement

The Kingdom of Takahashi has N towns, numbered 1 through N.

There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i.

Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K times from there.

Help the king by writing a program that answers this question.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq A_i \leq N

1 \leq K \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the integer representing the town the king will be in if he starts at Town 1 and uses a teleporter exactly K times from there.

Sample Input 1

4 5
3 2 4 1

Sample Output 1

4

If we start at Town 1 and use the teleporter 5 times, our travel will be as follows: 1 \to 3 \to 4 \to 1 \to 3 \to 4.

Sample Input 2

6 727202214173249351
6 5 2 5 3 2

Sample Output 2

2


#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
}

int main(void)
{
    lli N, K;
    cin >> N >> K;
    vector<int> a;
    for (int i = 0; i < N; i++)
    {
        lli tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    vector<int> b;
    bool f[N + 1];
    fill(f, f + N + 1, false);
    lli route = 0;
    lli next = 1;
    lli rec;
    //f[1] = true;
    lli cnt = 0;
    while (1)
    {
        if (f[next] == false)
        {
            f[next] = true;
            next = a[route];
            route = next - 1;
            cnt++;
        }
        else
        {
            rec = next;
            break;
        }
    }
    cnt--;
    int vi[N + 1];
    fill(vi, vi + N + 1, 0);
    K -= cnt;
    lli memo = cnt;
    cnt = 0;
    while (1)
    {
        if (f[next] == false && vi[rec] != 2)
        {
            f[next] = true;
            next = a[route];
            route = next - 1;
            cnt++;
        }
        else
        {
            //rec = next;
            break;
        }
    }
    cnt--;
    if (K % (cnt - memo) == 0)
    {
        cout << K % (cnt - memo) + N << endl;
    }
    else
    {
        cout << K % (cnt - memo) << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
  long N,K;cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);//　テレポーター指示
  vector<int> B(N+1,0);//これまで到着した町
  B.at(0)=1;
  long count=0;
  int temp=1;
  //long j=0;
  long J;
  //long J,X;
 /* while(count<N){
    count++;
    temp=A.at(temp-1);
    B.at(count)=temp;
    while(j<count){//これまで到着した街と、今count回目に到着した街が同じならループ
      if(B.at(j)==temp){
        J=j;
        X=count;
        count=N+1;
        break;
      }
      j++;
    }
    j=0;
  }
  // J<XかつB.at(J)==B.at(X)である、最初のペア
  long roop=X-J;
  long ans=(K-J)%roop+J;
  cout<<B.at(ans)<<endl; */
  bool can=true;
  int repeat;
  while(can){
    count++;
    temp=A.at(temp-1);
    B.at(count)=temp;
    for(int i=0;i<count;i++){
      if(B.at(i)==temp){
        can=false;
        J=i;
        break;
      }
    }
  }
  repeat=count-J;
  if(K>count){
    K -= count;
    long ans=(K%repeat)+J;
    cout<<B.at(ans)<<endl;
  }
  else cout<<B.at(K)<<endl;
}


#include <bits/stdc++.h>
using namespace std;

//解説AC

int main(){
    int n;
    long long k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }

    deque<int> b;
    vector<bool> seen(n,false);
    int tmp = 0;
    while(true){
        if(seen[tmp]){
            while(b[0] != tmp){
                k--;
                b.pop_front();

                if(k == 0){
                    cout << a[0] + 1 << endl;
                    return 0;
                }
            }
            break;
        }
        b.push_back(tmp);
        seen[tmp] = true;
        tmp = a[tmp];
    }
    cout << b[k % b.size()] + 1 << endl;

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
using namespace std;
const int INF = 1e18;
const int MOD = 1000000007;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n)
    {
        cin >> a[i];
        a[i]--;
    }
    vector<int> record(0);
    record.emplace_back(0);
    map<int, int> mp;
    mp[0]++;
    int pos = 0;
    while (true)
    {
        if (mp[a[pos]])
        {
            record.push_back(a[pos]);
            break;
        }
        mp[a[pos]]++;
        record.emplace_back(a[pos]);
        pos = a[pos];
    }

    int loop = 0;
    reverse(ALL(record));
    rep(i, record.size())
    {
        if (i != 0 && record[i] == record[0])
            break;
        loop++;
    }
    reverse(ALL(record));

    int front = record.size() - loop - 1;
    if (k <= front)
    {
        cout << record[k - 1] << endl;
    }
    else
    {
        int rest = (k - front) % loop;
        cout << record[front + rest] + 1 << endl;
    }
}

signed main()
{
    solve();
    return 0;
}


#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
#include <iomanip>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007
#define pi 3.14159265358979323846264338327950

ll all[maxN] = {};
bool vis[maxN] = {};

void solve()
{
    ll n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> all[i];
    }
    vis[1] = true;
    int now = 1;
    while (1)
    {
        now = all[now];
        if (vis[now])
        {
            break;
        }
        vis[now] = true;
    }
    //cout<<"start: "<<now<<endl;
    int start = now;
    for (int i = 0; i <= n; i++)
    {
        vis[i] = 0;
    }
    vector<int> path;
    while (1)
    {
        path.push_back(start);
        vis[start] = true;
        start = all[start];
        if (vis[start])
        {
            break;
        }
    }
    //cout <<path.size() << endl;
    for (int i = 0; i <= n; i++)
    {
        vis[i] = 0;
    }
    int temp = 1;
    while (1)
    {
    	if(k==1){
    		cout<<temp<<endl;
    		return;
		}
    	if (temp == now)
        {
            break;
        }
        temp = all[temp];
        k--;
    }
    cout << path[k % path.size()] << endl;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
}


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

int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<int> s;
  vector<int> ord(n+1, -1);
  int c = 1, l = 0;
  {
    int v = 1;
    while (ord[v] == -1) {
      ord[v] = s.size();
      s.push_back(v);
      v = a[v-1];
    }
    c = s.size() - ord[v];
    l = ord[v];
  }

  if (k < l) cout << s[k] << endl;
  else {
    k -= l;
    k %= c;
    cout << s[l+k] << endl;
  }
  return 0;
}


#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	lli n, k, cnt = 0, basho=0, ans;
	cin >> n >> k;
	vector<lli> a(n+1);
	map<lli, int> memo;
	loop(i, 1, n+1) cin >> a[i];

	int flag = 0;
	memo[1]++;
	lli old = 1;
	vector<lli> q(1,1);//初期設定

	rep(i,n+1){
		memo[a[old]]++;
		if(memo[a[old]] > 1){
			flag = 1;
			for(const auto& x : q){
				if(x == a[old]) break;
				basho++;
			}
		}
		if(flag == 1) break;
		q.push_back(a[old]);
		old = a[old];
	}//ループし始める要素の先頭になったら
	//その要素の過去に出た場所を特定する

	if(k < basho) ans = q[k];
	else if(basho == 0){
		if(k <= q.size()-1) ans = q[k];
		else{
			k -= (q.size());
			k %= q.size();
			ans = q[k];
		}
	}else{
		k -= (basho);
		lli youso = q.size()-basho;
		k %= youso;
		ans = q[basho+k];
	}
	cout << ans << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

#define ll long long int
#define mod 1000000007

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

  ll n, k;
  cin >> n >> k;
  vector<pair<ll,bool>> vec;
  for(ll i = 0; i < n;i++){
      ll x;
      cin >> x;
      vec.push_back(make_pair(x,false));
  }
  if(k <= n){
       int i = 0;
  ll x = 0;
    for(;x < k;x++){
          i = vec[i].first - 1;

    }
    cout << i+1;
  }
  else{
  int i = 0;
  ll x = 0;
    for(;x < k;x++){
      if(vec[i].second == false){
          vec[i].second = true;
          i = vec[i].first - 1;

      }
      else
      break;
  }
  for(ll b = 0;b<vec.size();b++){
      vec[b].second = false;
  }

  ll p =0;
  for(;p<k;p++){
       if(vec[i].second == false){
          vec[i].second = true;
          i = vec[i].first - 1;

      }
      else
      break;
  }
  k = k-x;
  k = k%p;

  for(ll q = 1;q<=k;q++){
      i = vec[i].first - 1;
  }
  cout << i+1;
  }

}


#include <bits/stdc++.h>
typedef long long int ll;
const ll N=2*1e5+10;
using namespace std;
ll a[N];

int main() {
	// your code goes here
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);
	// cout.tie(NULL);
	ll n,k;
    cin>>n>>k;

    for(int i=1;i<=n;i++)
    cin>>a[i];
    vector<ll>c;
    vector<int>vis(n+1,0);
    int next=1;
    while(!vis[a[next]])
    {
    	vis[a[next]]=1;
    	c.push_back(a[next]);
    	next=a[next];
    }
    ll z=c.size();
    // for(auto i:c)
    // cout<<i<<"\n";
    if(k<=z)
    {
    	cout<<c[k-1];
    	return 0;
    }

    ll idx=0;
    for(int i=0;i<z;i++)
    {
    	if(c[i]==a[c[z-1]])
    	{
    		idx=i;
    		break;
    	}
    }
    ll size=k-idx;

    	ll r=size%(z-idx);
    	//cout<<r<<"\n";

    	if(r==0)
    	cout<<c[z-1];
    	else
    	cout<<c[idx+r-1];

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
int n;
map <int, int> pos;
map <int, bool> vis;
int seq[maxx];
LL k;

int main() {
	scanf("%d %lld", &n , &k);
	for(int i = 1; i <= n; i++) scanf("%d", &pos[i]);
	int nxt = 1;
	int t = -1;
	seq[++t] = nxt;
	int i = 1;
	while(!vis[i]) {
		vis[nxt] = 1; //先打标记
		nxt = pos[i]; //更新nxt
		seq[++t] = nxt;
		i = nxt; //替换
	}
	//seq[t]是第一次重复的数字
	//定位第一次出现时的位置fir
	int x = 0;
	for(int j = 0; j < t; j++) {
		if(seq[j] == seq[t]) {
			x = j;
			break;
		}
	}
	//cout << x << endl;
	if(k <= x) printf("%d\n", seq[k]);
	else {
		k -= (LL)x;
		LL id = k % ((LL)t - (LL)x);
		printf("%d\n", seq[x + id]);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(void){
    int N;
    int64_t K;
    cin >> N >> K;
    vector<pair<int, int>> A(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        A.at(i) = make_pair(--x, 0);
    }

    int count = 0;
    int ptr = A.at(0).first;
    for (;;) {
        ptr = A.at(ptr).first;
        A.at(ptr).second++;
        count ++;
        if (A.at(ptr).second >= 2) {
            count--;
            break;
        }
    }
    int count2;
    for (int i = 0; i < N; i++) {
        if (A.at(i).second == 1) {
            count2++;
        }
    }
    count -= count2;
    K %= count;
    for (int64_t i = 0; i < K - 1; i++) {
        ptr = A.at(ptr).first;
    }
    cout << ptr + 1 << endl;

}


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

int main() {
  ll n,k=0;
  cin>>n>>k;
  vector<ll> vec(n);
  ll now=0;
  for(ll i=0;i<n;i++){
    cin>>vec.at(i);
  }
  vector<ll> nowvec(n);
  ll loop,loopStart,untilLoop=0;
  bool looped=false;

  for(ll i=0;i<k;i++){
    nowvec.at(i)=now;
    now=vec.at(now)-1;
    //nowvec.at(i)=now;
    for(ll j=0;j+1<i;j++){
      if(nowvec.at(j)==now){
        loop=i-j+1;
        loopStart=now;
        untilLoop=j;
        looped=true;
        break;
      }
    }
    if(looped){
      break;
    }
  }

  if(looped){
    //cout<<loop;
    k-=untilLoop;
    //cout<<loopStart<<endl;loopStartはOK
    //cout<<untilLoop<<endl;
    k=k%loop;
    //cout<<k<<endl;
    now=loopStart;
    //cout<<now<<endl;
    for(ll i=0;i<k;i++){
      now=vec.at(now)-1;
      cout<<now<<endl;
    }
  }
  cout<<now+1;
}


#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <climits>
using namespace std;
using ll = long long;
int memo[(unsigned int)2e5];
int main() {
  int n; ll k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  //memo : その町がいくつ目の町か
  int next = 1;
  int it = 1;
  do {
    memo[next - 1] = it++;
    next = a[next - 1];
  } while (memo[next - 1] == 0 && it < k + 1);
  if (it == k + 1) {
    cout << next << endl;
    return 0;
  }
  int t = it - memo[next - 1];
  k -= memo[next - 1] - 1; //ループに入る前に通った町の数
  k %= t;
  while (k-- > 0) {
    next = a[next - 1];
  }
  cout << next << endl;
  return 0;
}


#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  ll k;
  cin >> n >> k;
  int a[n];
  rep(i, n) {
    cin >> a[i];
    --a[i];
  }

  vector<int> d;
  d.push_back(0);
  set<int> v;
  int loop = 0;
  for (int i = 0; i < n - 1; ++i) {
    int nx = a[d[i]];
    if (v.find(nx) != v.end()) {
      loop = d.size() - distance(d.begin(), find(d.begin(), d.end(), nx));
      break;
    }
    d.push_back(nx);
    v.insert(nx);
  }

  int noLoop = d.size() - loop;
  int ans = d[noLoop + (k - noLoop) % loop];
  cout << ++ans << '\n';

  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0 ; i<(n) ; ++i)
typedef long long ll;
using namespace std;
const ll MAX = 2500LL;
typedef pair <ll, ll> P;

using Graph = vector<vector<int>>;
// 探索
vector<bool> seen, finished;
int pos = -1; // サイクル中に含まれる頂点 pos
stack<int> hist; // 訪問履歴

void dfs(const Graph &G, int v, int p) {
    seen[v] = true;
    hist.push(v);
    for (auto nv : G[v]) {
        if (nv == p) continue; // 逆流を禁止する

        // 完全終了した頂点はスルー
        if (finished[nv]) continue;

        // サイクルを検出
        if (seen[nv] && !finished[nv]) {
            pos = nv;
            return;
        }

        // 再帰的に探索
        dfs(G, nv, v);

        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) return;
    }
    hist.pop();
    finished[v] = true;
}
int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  Graph G(n);
  rep(i,n){
    int n_y;
    cin >> n_y;
    --n_y;
    a[i] = n_y;
    G[i].push_back(a[i]);
  }
  seen.assign(n, false), finished.assign(n, false);
  pos = -1;
  dfs(G, 0, -1);

  // サイクルを復元
  set<int> cycle;
  while (!hist.empty()) {
      int t = hist.top();
      cycle.insert(t);
      hist.pop();
      if (t == pos) break;
  }
  //cout << cycle.size() << endl;
  auto itr = cycle.begin();
  ll count = 0;
  int y=0;
  while(true){
    int j = a[y];
    count++;
    if(j == *itr){
      break;
    }
    y = j;
  }

  ll re = k - count;
  int amari = re%cycle.size();
  int ans;
  int z=*itr;
  for(int i=0; i<amari; i++){
    //int z = *itr;
    int j = a[z];
    z = j;
    ans = z;
  }
  cout << ans+1 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

int N;
long long K;
vector<int> A, T;

int main()
{
  cin >> N >> K;
  A.resize(N + 1);
  for (int i = 1; i <= N; i++)
  {
    cin >> A.at(i);
  }
  T.resize(N + 1, -1);
  int timer = 0;
  int next = 1;
  int loop_size, q;
  while (1)
  {
    if (T.at(next) != -1)
    {
      loop_size = timer - T.at(next);
      q = T.at(next);
      break;
    }
    T.at(next) = timer;
    next = A.at(next);
    timer++;
  }
  int loop_times = 0;
  if (K < q)
  {
    loop_times = K;
  }
  else
  {
    loop_times = ((K - q) % loop_size) + q;
  }
  int ans = 1;
  for (int i = 0; i < loop_times; i++)
  {
    ans = A.at(ans);
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 2e5+7;
int a[N],b[N];
inline void solve()
{
	ll n,k;cin>>n>>k;
	queue<int> que; que.push(1);
	map<int,int> mp;mp[1]=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	int x= a[1];
	for(int i=1;i<=n;i++)
	{
		if(!mp.count(x)) mp[x] = i,que.push(x),x=a[x];
		else
		{
			while(que.front()!=x)
			{
				k--;
				que.pop();
			}
			k++;
			ll p = k%que.size();
			if(p==0) p=que.size();

			int cnt = 1;
			while(que.size())
			{
				if(cnt == p)
				{
					cout<<que.front()<<endl;
					break;
				}
				que.pop();
				cnt++;
			}
			break;
		}

	}
}
int main()
{
	IOS();
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
template<class T> inline void YES(T condition) {
    if(condition) cout << "YES" << endl;
    else cout << "NO" << endl;
}
template<class T> inline void Yes(T condition) {
    if(condition) cout << "Yes" << endl;
    else cout << "No" << endl;
}
template<class T> T gcd(T a, T b) {
    if(a && b) { return gcd(min(a, b), max(a, b) % min(a, b)); }
    else { return a; }
}
template<class T> T lcm(T a, T b){
    return a / gcd(a, b) * b;
}
long long qpow(long long a, long long b, int MOD) {
    if (b == 0) return 1;
    long long res = 1;
    while (b) {
        if (b & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

const int MOD = 1e9 + 7;
const int maxn = 2e6;
int fac[maxn + 5];
int invfac[maxn + 5];
void init() {
    fac[0] = 1;
    for (int i = 1; i <= maxn; i++) fac[i] = 1LL * fac[i - 1] * i % MOD;
    invfac[maxn] = (int)(qpow(fac[maxn], MOD - 2, MOD));
    for (int i = maxn - 1; i >= 0; i--) invfac[i] = 1LL * invfac[i + 1] * (i + 1) % MOD;
}
int C(int n, int k) {
    assert(0 <= k && n >= k);
    int tmp = (int)(1LL * invfac[k] * invfac[n - k] % MOD);
    return (int)(1LL * fac[n] * tmp % MOD);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    LL n, k;
    cin >> n >> k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<int> seen(n + 1, 0);
    seen[1] = 1;
    int cur = 1;
    int cnt = 1;
    vector<int> kth;
    kth.push_back(1);
    map<int, int> idx;
    idx[a[1]] = 0;
    int start;
    int round;
    while (true) {
        int nxt = a[cur];
        if (seen[nxt]) {
            start = idx[nxt];
            round = cnt - idx[nxt];
            break;
        }
        seen[nxt] = true;
        idx[nxt] = cnt;
        cnt++;
        kth.push_back(nxt);
        cur = nxt;
    }
    // cout << start << "  " << round << endl;
    if (k <= start) {
        cout << kth[k] << '\n';
        return 0;
    }
    k = (k - start) % round;
    // cout << idx << '\n';
    // cout << kth << '\n';
    cout << kth[start + k] << '\n';

    return 0;
}


#include<cstdio>
long long n,k,a[500005],f[500005],cnt;
int dfs(int i,int k){
    if(k==0)return i;
    if(!f[i])return f[i]=cnt++,dfs(a[i],k-1);
    else{
        k%=(cnt-f[i]);int ret=i;
        for(int i=1;i<=k;i++)ret=a[ret];
        return ret;
    }
}
int main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++)scanf("%lld",a+i);
    printf("%d\n",dfs(1,k));
}


// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)...}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__) << '\n'
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin {
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on

template <int levels = 62> struct BinLift {
	vector<vector<int>> down;

	BinLift(vector<int> tele): down(levels) {
		down[0] = move(tele);
		Build();
	}

	template <typename It> BinLift(It first, It last) : down(levels) {
		down[0].assign(first, last);
		Build();
	}

	void Build() {
		int sz = down[0].size();
		for (int l = 1; l < levels; ++l) {
			down[l].resize(sz);
			for (int u = 0; u < sz; ++u) {
				down[l][u] = down[l - 1][down[l - 1][u]];
			}
		}
	}

	auto LookUp(int u, ll k) {
		for (int l = levels - 1; l >= 0; --l) {
			if (k & (1ll << l)) u = down[l][u];
		}
		return u;
	}
};

auto Main() {
	ll n,k;
	cin>>n>>k;
	vector<int> A(n+1);
	FOR(i,1,n+1)cin>>A[i];

	auto bl = BinLift<>{A};

	cout << bl.LookUp(1, k);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}