import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main
{
	public void foo()
	{
		MyScanner scan = new MyScanner();
		int n = scan.nextInt();
		int b = scan.nextInt();
		int preMin = scan.nextInt();
		int maxSum = b;
		for(int i = 1;i < n;++i)
		{
			int a = scan.nextInt();
			if(a > preMin)
			{
				maxSum = Math.max(maxSum, b % preMin + b / preMin * a);
			}
			else
			{
				preMin = a;
			}
		}
		System.out.println(maxSum);
	}

	public static void main(String[] args)
	{
		new Main().foo();
	}

	class MyScanner
	{
	    private byte[] buf = new byte[1024];
	    private int curChar;
	    private int numChars;
	    BufferedInputStream bis = new BufferedInputStream(System.in);

	    public int read()
	    {
	        if (-1 == numChars)
	        {
	        	throw new InputMismatchException();
	        }
	        if (curChar >= numChars)
	        {
	            curChar = 0;
	            try
	            {
	                numChars = bis.read(buf);
	            }
	            catch (IOException e)
	            {
	                throw new InputMismatchException();
	            }
	            if (numChars <= 0)
	            {
	            	return -1;
	            }
	        }
	        return buf[curChar++];
	    }

	    public int nextInt()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        int res = 0;
	        do
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public long nextLong()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        int sgn = 1;
	        if (c == '-')
	        {
	            sgn = -1;
	            c = read();
	        }
	        long res = 0;
	        do
	        {
	            if (c < '0' || c > '9')
	            {
	            	throw new InputMismatchException();
	            }
	            res *= 10;
	            res += c - '0';
	            c = read();
	        } while (!isSpaceChar(c));
	        return res * sgn;
	    }

	    public String next()
	    {
	        int c = read();
	        while (isSpaceChar(c))
	        {
	        	c = read();
	        }
	        StringBuilder res = new StringBuilder();
	        do
	        {
	            res.appendCodePoint(c);
	            c = read();
	        } while (!isSpaceChar(c));
	        return res.toString();
	    }

	    private boolean isSpaceChar(int c)
	    {
	        return ' ' == c || '\n' == c || '\r' == c || '\t' == c || -1 == c;
	    }
	}
}


 #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef long long ll;
#define inf 0x3f3f3f3f
#define finf -0x3f3f3f3f
#define Fi first
#define Se second
#define forni(i, n)  for(i=0;i<n;i++)
#define forni1(i, n)  for(i=1;i<=n;i++)
#define fornj(j, n)  for(j=0;j<n;j++)
#define fornj1(j, n)  for(j=1;j<=n;j++)
#define sr read()
#define scNO printf("NO\n");
#define scNo printf("No\n");
#define scno printf("No\n");
#define scnn printf("no\n");
#define sc0 printf("0\n");
#define sc1 printf("1\n");
#define	scf1 printf("-1\n");
#define	scz1 printf("1\n");
#define scYES printf("YES\n");
#define scyes printf("yes\n");
#define scYes printf("Yes\n");
#define scyes printf("yes\n");
#define cn printf("\n");
#define mapp map<int ,int >mo
#define bug(a)  printf("%d \n ",a);
#define bugg(a,b)  printf("%d * %d \n",a,b);
#define buggg(a,b,c)  printf("%d * %d * %d \n",a,b,c);
#define bugggg(a,b,c,d)  printf("%d * %d * %d* %d\n",a,b,c,d);
#define endd  return 0;
#define mf	-1000000000000000000
long long Calculation(int y,int m,int d)
{
	if (m<3) {y-=1;m+=12;}
	return 365*y+y/4-y/100+y/400+(153*m-457)/5+d-306;
}
bool cmp(int a,int b ){
	return a>b;
}
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
inline string r(string n)
{
	string k="";
	for (int i=n.size()-1;i>=0;i--)
		k+=n[i];
	return k;
}
const long long modd=1e9+7;
long long quickpow(long long a,long long b){
        long long ret=1;
        while(b){
            if(b&1){
                ret=ret*a%modd;
            }
            a=a*a%modd;
            b>>=1;
        }
        return ret;
}
struct node{
	int x,y;
}cxy[8];

bool cmp1(node a,node b){
	return a.x<b.x||a.x==b.x&&a.y<b.y;
}
int cl(int x,int n)//换进制算法
{
	int s=0,i=0,w[101];
	while(x>=1)
	{
		w[++i]=x%n;
		x=x/n;
	}
	for(int j=i;j>=1;j--)
	   s=s*10+w[j];
	return s;
}

ll n,b,ans;
ll a[2010];
ll mer(int in,int out)
{
	ll bb,d;
	d=b/a[in];  bb=b%a[in];
	bb+=d*a[out];
	return bb;
}
int main()
{
  scanf("%lld%dll",&n,&b);
  for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
  for(int i=1;i<=n;i++)
   for(int j=i;j<=n;j++)
    ans=max(ans,mer(i,j)) ;
  cout<<ans<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b,i,j,ans=0,a[2005];
	cin>>n>>b;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ans=b;
	int d1=0;
	for(i=0;i<n-1;i++){
		if(a[i+1]>a[i]){
			int x;
			x=ans/a[i];
			d1+=x;
			ans-=(x)*a[i];
		}
		else {
			int y;
			y=d1*a[i];
			ans+=y;
		}
	}
	ans+=(d1*a[i]);
	cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b,i,j,ans=0,a[2005];
	cin>>n>>b;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	ans=b;
	int d1=0;
	for(i=0;i<n-1;i++){
		if(a[i+1]>a[i]){
			int x;
			x=ans/a[i];
			d1+=x;
			ans-=(x)*a[i];
		}
		else {
			int y;
			y=d1*a[i];
			ans+=y;
			d1=0;
		}
	}
	ans+=(d1*a[i]);
	cout<<ans<<endl;
}


#include<cstdio>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;if(p>=n-1)return;
		while(bb[q][1]!=p)q++;
		slove(p,q,b);
	}
}
int main(){
	int b;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	if(p>=n-1)return ;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;if(p>=n-1)return;
		while(bb[q][1]!=p)q++;
		slove(p,q,b);
	}
}
int main(){
	int b;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);printf("%d",ans);
	return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
long long aa[2005],bb[2005][2],ans;
int n;
int cmp(const void* aa,const void *bb){
	long long *a=(long long *)aa;
	long long *b=(long long *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,long long b){
	int a;long long m;
	if(p>=n-1||q>=n-1)return ;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;if(p>=n-1)return;
		while(bb[q][1]!=p)q++;
		slove(p,q,b);
	}
}
int main(){
	long long b;cin>>n>>b;ans=b;
	for(int i=0;i<n;i++){
		cin>>aa[i];
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
long long aa[2005],bb[2005][2],ans;
int n;
int cmp(const void* aa,const void *bb){
	long long *a=(long long *)aa;
	long long *b=(long long *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,long long b){
	int a;long long m;
	if(p>=n-1||q>=n-1)return ;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;if(p>=n-1)return;
		while(bb[q][1]!=p)q++;
		slove(p,q,b);
	}
}
int main(){
	long long b;cin>>n>>b;ans=b;
	for(int i=0;i<n;i++){
		cin>>n>>b;
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);cout<<ans;
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	if(p>=n-1||q>=n-1)return ;
	if(p==bb[q][1]){p++;q++;slove(p,q,b);}
	else if(p>bb[q][1]){
		while(bb[q][1]<p&&q<n)q++;if(q==n)return;
	}
	if(aa[p]>=bb[q][0]){p++;q++;slove(p+1,q+1,b);}
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];ans=max(ans,b+(bb[q][0]-aa[a])*m);//printf("%d\n",ans);
		p=bb[q][1]+1;
		slove(p,q,b);
	}
}
int main(){
	int b;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	while(p==bb[q][1]&&q<n)p++,q++;
	if(q==n)return ;
	a=p;
	for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
	m=b/aa[a];ans=max(ans,b+(bb[q][0]-aa[a])*m);//printf("%d\n",ans);
	if(bb[q][1]<n-2){
		p=bb[q][1];
		while(bb[q][1]<=p&&q<n&&aa[p]>=bb[q][0])q++;if(q==n)return ;
		slove(p,q,b);
	}
}
int main(){
	int b,a;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	slove(0,0,b);
	printf("%d",ans);
	return 0;
}


#include<cstdio>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	if(p>=n-1)return;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;
		p=bb[q][1]+1;while(bb[q][1]<p)q++;
		slove(p,q,b);
	}
}
int main(){
	int b;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);printf("%d",ans);
	return 0;
}


#include<iostream>
#include<cstdlib>
using namespace std;
long long aa[2005],bb[2005][2],ans;
int n;
int cmp(const void* aa,const void *bb){
	long long *a=(long long *)aa;
	long long *b=(long long *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,long long b){
	int a;long long m;
	if(p>=n-1||q>=n-1)return ;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;if(p>=n-1)return;
		while(bb[q][1]!=p&&q<n)q++;
		slove(p,q,b);
	}
}
int main(){
	long long b;cin>>n>>b;ans=b;
	for(int i=0;i<n;i++){
		cin>>aa[i];
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);cout<<ans;
	return 0;
}


#include<cstdio>
#include<cstdlib>
using namespace std;
int aa[2005],bb[2005][2],ans,n;
int cmp(const void* aa,const void *bb){
	int *a=(int *)aa;
	int *b=(int *)bb;
	if(*a==*b)return *(a+1)-*(b+1);
	else return *(b)-*(a);
}
void slove(int p,int q,int b){
	int a,m;
	if(p>=n-1)return;
	if(aa[p]>=bb[q][0])slove(p+1,q+1,b);
	else{
		a=p;
		for(int i=p+1;i<bb[q][1];i++)if(aa[i]<aa[a])a=i;
		m=b/aa[a];b+=(bb[q][0]-aa[a])*m;ans=b;//printf("%d\n",ans);
		p=bb[q][1]+1;while(bb[q][1]!=p)q++;
		slove(p,q,b);
	}
}
int main(){
	int b;scanf("%d%d",&n,&b);ans=b;
	for(int i=0;i<n;i++){
		scanf("%d",&aa[i]);
		bb[i][0]=aa[i];bb[i][1]=i;
	}
	qsort(bb,n,sizeof(bb[0]),cmp);
	//for(int i=0;i<n;i++)printf("%d %d\n",bb[i][0],bb[i][1]);
	slove(0,0,b);printf("%d",ans);
	return 0;
}


#include <cstdio>
#include <cstdlib>
int n,b,i,a[2001],max,j,s,c;
int main () {
scanf ("%d %d",&n,&b);
for (i=1;i<=n;i++)
scanf ("%d",&a[i]);
max=b;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++) {
						s=b;
						c=s/a[i];
						s=s%a[i];
						s=s+c*a[j];
						if (max<s) max=s;
						}
printf ("%d",max);
return 0;
}


/*******************************
*  بسم الله الرحمن الرحيم
*  Harunur Rashid
********************************

************Template Starts Here***********/

#include<bits/stdc++.h>

using namespace std;

#define endl       "\n"
#define eps        1e-9
#define sf         scanf
#define xx         first
#define yy         second
#define pf         printf
#define ppb        pop_back
#define sqr(x)     ((x)*(x))
#define mp         make_pair
#define pb         push_back
#define pi         acos(-1.0)
#define mod        1000000007
#define degree(a)  180.0*a/pi
#define radiun(a)  pi*a/180.0
#define pr(a)      cout<<a<<"\n"
#define sz(x)      ((int)x.size())
#define all(a)     a.begin(),a.end()
#define mem(a,b)   memset(a,b,sizeof(a))
#define leadingzero(x) __builtin_clz(x)
#define trailingzero(x) __builtin_ctz(x)
#define countbit(x) __builtin_popcount(x)
#define lcm(a,b)   (abs(a)/gcd(a,b))*abs(b)

typedef long long int          LL;
typedef unsigned long long int LLU;
typedef vector<int>            vi;
typedef pair<int,int>          pii;

template<class T>
T mod_f(T num)
{
    if(num>=0) return num%mod;
    else       return ((num%mod)+mod)%mod;
}

template<class T>
T fast_pow(T b,T p)
{
    if(p==0)
        return 1;
    if(p%2)
    {
        T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
        return x;
    }
    else
    {
        T x=mod_f(fast_pow(b,p/2));
        x=mod_f(mod_f(x)*mod_f(x));
        return x;
    }
}

template<class T>
T gcd(T a,T b)
{
    a=abs(a);
    b=abs(b);
    while(b)
    {
        T r=a%b;
        a=b;
        b=r;
    }
    return a;
}

template<class T>
ostream& operator<<(ostream& out,vector<T>v)
{
    int sz=v.size()-1;
    for(int i=0; i<=sz; i++) out<<v[i]<<" ";
    return out;
}

template<class T>
ostream& operator,(ostream& out,T a)
{
    out<<a<<" ";
    return out;
}

/* int gcd , x , y
void extendedEuclid(int A,int B)
{
    if(B==0)
    {
        gcd=A;
        x=1;
        y=0;
    }
    else
    {
        extendedEuclid(B,A%B);
        int u=x;
        x=y;
        y=u-(A/B)*y;
    }
}
*/
//bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
//bool isLessThan(double a,double b) { return a+eps<b; }
//bool isLessThanEqual(double a,double b) { return a<b+eps; }
//bool isGreaterThan(double a,double b) { return a>b+eps; }
//bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
//bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
//int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
//bool isUpper(char c){return c>='A' && c<='Z';}
//bool isLower(char c){return c>='a' && c<='z';}

/*/ 4 direction ....

int dx[]= {+0,+1,+0,-1};
int dy[]= {+1,+0,-1,+0};

// 8 direction ....

int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};

// Knight direction...

int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
*/

/***********Template Ends Here***********/

vi a(2000);

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
    int n,i,k,Start,End,mx,mn,mxp,c,ans;
    LL b;
    cin>>n>>b;
    for(i=0; i<n; i++) cin>>a[i];
    ans=k=0;
    while(1)
    {
        if(k>=n-1) break;
        for(mx=0,i=k+1; i<n; i++)
        {
            if(a[i]>mx)
            {
                mx=a[i];
                mxp=i;
            }
        }
        for(mn=3000,i=k; i<mxp; i++) mn=min(mn,a[i]);
        if(mn<mx)
        {
            c=b/mn;
            c=b-c*mn+c*mx;
        }
        ans=max(ans,c);
        k=mxp+1;
    }
    cout<<ans<<endl;
    return 0;
}


/*******************************
*  بسم الله الرحمن الرحيم
*  Harunur Rashid
********************************

************Template Starts Here***********/

#include<bits/stdc++.h>

using namespace std;

#define endl       "\n"
#define eps        1e-9
#define sf         scanf
#define xx         first
#define yy         second
#define pf         printf
#define ppb        pop_back
#define sqr(x)     ((x)*(x))
#define mp         make_pair
#define pb         push_back
#define pi         acos(-1.0)
#define mod        1000000007
#define degree(a)  180.0*a/pi
#define radiun(a)  pi*a/180.0
#define pr(a)      cout<<a<<"\n"
#define sz(x)      ((int)x.size())
#define all(a)     a.begin(),a.end()
#define mem(a,b)   memset(a,b,sizeof(a))
#define leadingzero(x) __builtin_clz(x)
#define trailingzero(x) __builtin_ctz(x)
#define countbit(x) __builtin_popcount(x)
#define lcm(a,b)   (abs(a)/gcd(a,b))*abs(b)

typedef long long int          LL;
typedef unsigned long long int LLU;
typedef vector<int>            vi;
typedef pair<int,int>          pii;

template<class T>
T mod_f(T num)
{
    if(num>=0) return num%mod;
    else       return ((num%mod)+mod)%mod;
}

template<class T>
T fast_pow(T b,T p)
{
    if(p==0)
        return 1;
    if(p%2)
    {
        T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
        return x;
    }
    else
    {
        T x=mod_f(fast_pow(b,p/2));
        x=mod_f(mod_f(x)*mod_f(x));
        return x;
    }
}

template<class T>
T gcd(T a,T b)
{
    a=abs(a);
    b=abs(b);
    while(b)
    {
        T r=a%b;
        a=b;
        b=r;
    }
    return a;
}

template<class T>
ostream& operator<<(ostream& out,vector<T>v)
{
    int sz=v.size()-1;
    for(int i=0; i<=sz; i++) out<<v[i]<<" ";
    return out;
}

template<class T>
ostream& operator,(ostream& out,T a)
{
    out<<a<<" ";
    return out;
}

/* int gcd , x , y
void extendedEuclid(int A,int B)
{
    if(B==0)
    {
        gcd=A;
        x=1;
        y=0;
    }
    else
    {
        extendedEuclid(B,A%B);
        int u=x;
        x=y;
        y=u-(A/B)*y;
    }
}
*/
//bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
//bool isLessThan(double a,double b) { return a+eps<b; }
//bool isLessThanEqual(double a,double b) { return a<b+eps; }
//bool isGreaterThan(double a,double b) { return a>b+eps; }
//bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
//bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
//int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
//bool isUpper(char c){return c>='A' && c<='Z';}
//bool isLower(char c){return c>='a' && c<='z';}

/*/ 4 direction ....

int dx[]= {+0,+1,+0,-1};
int dy[]= {+1,+0,-1,+0};

// 8 direction ....

int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};

// Knight direction...

int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
*/

/***********Template Ends Here***********/

vi a(2000);

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
    int n,i,k,Start,End,mx,mn,mxp,c,ans;
    LL b;
    cin>>n>>b;
    for(i=0; i<n; i++) cin>>a[i];
    ans=b;
    k=0;
    while(1)
    {
        if(k>=n-1) break;
        for(mx=0,i=k+1; i<n; i++)
        {
            if(a[i]>mx)
            {
                mx=a[i];
                mxp=i;
            }
        }
        for(mn=3000,i=k; i<mxp; i++) mn=min(mn,a[i]);
        if(mn<mx)
        {
            c=b/mn;
            c=b-c*mn+c*mx;
        }
        ans=max(ans,c);
        k=mxp+1;
    }
    cout<<ans<<endl;
    return 0;
}


/*******************************
*  بسم الله الرحمن الرحيم
*  Harunur Rashid
********************************

************Template Starts Here***********/

#include<bits/stdc++.h>

using namespace std;

#define endl       "\n"
#define eps        1e-9
#define sf         scanf
#define xx         first
#define yy         second
#define pf         printf
#define ppb        pop_back
#define sqr(x)     ((x)*(x))
#define mp         make_pair
#define pb         push_back
#define pi         acos(-1.0)
#define mod        1000000007
#define degree(a)  180.0*a/pi
#define radiun(a)  pi*a/180.0
#define pr(a)      cout<<a<<"\n"
#define sz(x)      ((int)x.size())
#define all(a)     a.begin(),a.end()
#define mem(a,b)   memset(a,b,sizeof(a))
#define leadingzero(x) __builtin_clz(x)
#define trailingzero(x) __builtin_ctz(x)
#define countbit(x) __builtin_popcount(x)
#define lcm(a,b)   (abs(a)/gcd(a,b))*abs(b)

typedef long long int          LL;
typedef unsigned long long int LLU;
typedef vector<int>            vi;
typedef pair<int,int>          pii;

template<class T>
T mod_f(T num)
{
    if(num>=0) return num%mod;
    else       return ((num%mod)+mod)%mod;
}

template<class T>
T fast_pow(T b,T p)
{
    if(p==0)
        return 1;
    if(p%2)
    {
        T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
        return x;
    }
    else
    {
        T x=mod_f(fast_pow(b,p/2));
        x=mod_f(mod_f(x)*mod_f(x));
        return x;
    }
}

template<class T>
T gcd(T a,T b)
{
    a=abs(a);
    b=abs(b);
    while(b)
    {
        T r=a%b;
        a=b;
        b=r;
    }
    return a;
}

template<class T>
ostream& operator<<(ostream& out,vector<T>v)
{
    int sz=v.size()-1;
    for(int i=0; i<=sz; i++) out<<v[i]<<" ";
    return out;
}

template<class T>
ostream& operator,(ostream& out,T a)
{
    out<<a<<" ";
    return out;
}

/* int gcd , x , y
void extendedEuclid(int A,int B)
{
    if(B==0)
    {
        gcd=A;
        x=1;
        y=0;
    }
    else
    {
        extendedEuclid(B,A%B);
        int u=x;
        x=y;
        y=u-(A/B)*y;
    }
}
*/
//bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
//bool isLessThan(double a,double b) { return a+eps<b; }
//bool isLessThanEqual(double a,double b) { return a<b+eps; }
//bool isGreaterThan(double a,double b) { return a>b+eps; }
//bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
//bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
//int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
//bool isUpper(char c){return c>='A' && c<='Z';}
//bool isLower(char c){return c>='a' && c<='z';}

/*/ 4 direction ....

int dx[]= {+0,+1,+0,-1};
int dy[]= {+1,+0,-1,+0};

// 8 direction ....

int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};

// Knight direction...

int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
*/

/***********Template Ends Here***********/

vi a(2000);

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
    int n,b,i,j,ans;
    cin>>n>>b;
    for(i=0; i<n; i++) cin>>a[i];
    for(ans=b,i=0; i<n; i++) for(j=i+1; j<n; j++) ans=max(ans,b-a[i]*(b/a[i])+a[j]*(b/a[i]));
    cout<<ans<<endl;
    return 0;
}


/*******************************
*  بسم الله الرحمن الرحيم
*  Harunur Rashid
********************************

************Template Starts Here***********/

#include<bits/stdc++.h>

using namespace std;

#define endl       "\n"
#define eps        1e-9
#define sf         scanf
#define xx         first
#define yy         second
#define pf         printf
#define ppb        pop_back
#define sqr(x)     ((x)*(x))
#define mp         make_pair
#define pb         push_back
#define pi         acos(-1.0)
#define mod        1000000007
#define degree(a)  180.0*a/pi
#define radiun(a)  pi*a/180.0
#define pr(a)      cout<<a<<"\n"
#define sz(x)      ((int)x.size())
#define all(a)     a.begin(),a.end()
#define mem(a,b)   memset(a,b,sizeof(a))
#define leadingzero(x) __builtin_clz(x)
#define trailingzero(x) __builtin_ctz(x)
#define countbit(x) __builtin_popcount(x)
#define lcm(a,b)   (abs(a)/gcd(a,b))*abs(b)

typedef long long int          LL;
typedef unsigned long long int LLU;
typedef vector<int>            vi;
typedef pair<int,int>          pii;

template<class T>
T mod_f(T num)
{
    if(num>=0) return num%mod;
    else       return ((num%mod)+mod)%mod;
}

template<class T>
T fast_pow(T b,T p)
{
    if(p==0)
        return 1;
    if(p%2)
    {
        T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
        return x;
    }
    else
    {
        T x=mod_f(fast_pow(b,p/2));
        x=mod_f(mod_f(x)*mod_f(x));
        return x;
    }
}

template<class T>
T gcd(T a,T b)
{
    a=abs(a);
    b=abs(b);
    while(b)
    {
        T r=a%b;
        a=b;
        b=r;
    }
    return a;
}

template<class T>
ostream& operator<<(ostream& out,vector<T>v)
{
    int sz=v.size()-1;
    for(int i=0; i<=sz; i++) out<<v[i]<<" ";
    return out;
}

template<class T>
ostream& operator,(ostream& out,T a)
{
    out<<a<<" ";
    return out;
}

/* int gcd , x , y
void extendedEuclid(int A,int B)
{
    if(B==0)
    {
        gcd=A;
        x=1;
        y=0;
    }
    else
    {
        extendedEuclid(B,A%B);
        int u=x;
        x=y;
        y=u-(A/B)*y;
    }
}
*/
//bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
//bool isLessThan(double a,double b) { return a+eps<b; }
//bool isLessThanEqual(double a,double b) { return a<b+eps; }
//bool isGreaterThan(double a,double b) { return a>b+eps; }
//bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
//bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
//int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
//bool isUpper(char c){return c>='A' && c<='Z';}
//bool isLower(char c){return c>='a' && c<='z';}

/*/ 4 direction ....

int dx[]= {+0,+1,+0,-1};
int dy[]= {+1,+0,-1,+0};

// 8 direction ....

int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};

// Knight direction...

int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
*/

/***********Template Ends Here***********/

vi a(2000);

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
    int n,i,k,Start,End,mx,mn,mxp,c;
    LL b;
    cin>>n>>b;
    for(i=0; i<n; i++) cin>>a[i];
    k=0;
    while(1)
    {
        if(k>=n-1) break;
        for(mx=0,i=k+1; i<n; i++)
        {
            if(a[i]>mx)
            {
                mx=a[i];
                mxp=i;
            }
        }
        for(mn=3000,i=k; i<mxp; i++) mn=min(mn,a[i]);
        if(mn<mx)
        {
            c=b/mn;
            b=b-c*mn+c*mx;
        }
        k=mxp+1;
    }
    cout<<b<<endl;
    return 0;
}


/*******************************
*  بسم الله الرحمن الرحيم
*  Harunur Rashid
********************************

************Template Starts Here***********/

#include<bits/stdc++.h>

using namespace std;

#define endl       "\n"
#define eps        1e-9
#define sf         scanf
#define xx         first
#define yy         second
#define pf         printf
#define ppb        pop_back
#define sqr(x)     ((x)*(x))
#define mp         make_pair
#define pb         push_back
#define pi         acos(-1.0)
#define mod        1000000007
#define degree(a)  180.0*a/pi
#define radiun(a)  pi*a/180.0
#define pr(a)      cout<<a<<"\n"
#define sz(x)      ((int)x.size())
#define all(a)     a.begin(),a.end()
#define mem(a,b)   memset(a,b,sizeof(a))
#define leadingzero(x) __builtin_clz(x)
#define trailingzero(x) __builtin_ctz(x)
#define countbit(x) __builtin_popcount(x)
#define lcm(a,b)   (abs(a)/gcd(a,b))*abs(b)

typedef long long int          LL;
typedef unsigned long long int LLU;
typedef vector<int>            vi;
typedef pair<int,int>          pii;

template<class T>
T mod_f(T num)
{
    if(num>=0) return num%mod;
    else       return ((num%mod)+mod)%mod;
}

template<class T>
T fast_pow(T b,T p)
{
    if(p==0)
        return 1;
    if(p%2)
    {
        T x=mod_f(mod_f(b)*mod_f(fast_pow(b,p-1)));
        return x;
    }
    else
    {
        T x=mod_f(fast_pow(b,p/2));
        x=mod_f(mod_f(x)*mod_f(x));
        return x;
    }
}

template<class T>
T gcd(T a,T b)
{
    a=abs(a);
    b=abs(b);
    while(b)
    {
        T r=a%b;
        a=b;
        b=r;
    }
    return a;
}

template<class T>
ostream& operator<<(ostream& out,vector<T>v)
{
    int sz=v.size()-1;
    for(int i=0; i<=sz; i++) out<<v[i]<<" ";
    return out;
}

template<class T>
ostream& operator,(ostream& out,T a)
{
    out<<a<<" ";
    return out;
}

/* int gcd , x , y
void extendedEuclid(int A,int B)
{
    if(B==0)
    {
        gcd=A;
        x=1;
        y=0;
    }
    else
    {
        extendedEuclid(B,A%B);
        int u=x;
        x=y;
        y=u-(A/B)*y;
    }
}
*/
//bool isEqual(double a,double b) { return fabs(a-b)<=eps; }
//bool isLessThan(double a,double b) { return a+eps<b; }
//bool isLessThanEqual(double a,double b) { return a<b+eps; }
//bool isGreaterThan(double a,double b) { return a>b+eps; }
//bool isGreaterThanEqual(double a,double b) { return a+eps>b; }
//bool Palindrome(string s) { return equal(s.begin(), s.end(), s.rbegin()); }
//int day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
//bool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}
//bool isUpper(char c){return c>='A' && c<='Z';}
//bool isLower(char c){return c>='a' && c<='z';}

/*/ 4 direction ....

int dx[]= {+0,+1,+0,-1};
int dy[]= {+1,+0,-1,+0};

// 8 direction ....

int dx[]= {+0,+1,+1,+1,+0,-1,-1,-1};
int dy[]= {+1,+1,+0,-1,-1,-1,+0,+1};

// Knight direction...

int dx[]= {+1,-1,+2,-2,+2,-2,+1,-1};
int dy[]= {+2,+2,+1,+1,-1,-1,-2,-2};
*/

/***********Template Ends Here***********/

vi a(2000);

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(false);cout.tie(false);
    int n,i,k,Start,End,mx,mn,mxp,c;
    LL b;
    cin>>n>>b;
    for(i=0; i<n; i++) cin>>a[i];
    k=0;
    while(1)
    {
        for(mx=0,i=k+1; i<n; i++)
        {
            if(a[i]>mx)
            {
                mx=a[i];
                mxp=i;
            }
        }
        for(mn=3000,i=k; i<mxp; i++) mn=min(mn,a[i]);
        if(mn<mx)
        {
            c=b/mn;
            b=b-c*mn+c*mx;
        }
        k=mxp+1;
        if(k>=n-1) break;
    }
    cout<<b<<endl;
    return 0;
}


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

int main(){
    int n,b,v,minn;
    scanf("%d %d",&n,&b);
    scanf("%d",&minn);
    int ans=b;
    for(int i=2;i<=n;i++){
        scanf("%d",&v);
        if(v>minn){
            ans=b%minn;
            ans+=(b/minn)*v;
        }
        else minn=v;
    }
    printf("%d\n",ans);
}


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

int main(){
    int n,b,v,minn;
    scanf("%d %d",&n,&b);
    scanf("%d",&minn);
    int ans=b,tmp;
    for(int i=2;i<=n;i++){
        scanf("%d",&v);
        if(v>minn){
            tmp=b%minn;
            tmp+=(b/minn)*v;
            ans=max(ans,tmp);
        }
        else minn=v;
    }
    printf("%d\n",ans);
}


#include<bits/stdc++.h>

using namespace std;

int main ()
{
int n,b,a[2000],ans=0,x;
cin>>n>>b;
for(int i=0;i<n;i++)
cin>>a[i];

for(int i=0;i<n-1;i++)
{if(a[i]<a[i+1])
{x=b/a[i];
ans=a[i+1]*x-a[i]*x;
b+=ans;
}

}
cout<<b;
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main ()
{
int n,b,a[2000],ans=0,x;
cin>>n>>b;
for(int i=0;i<n;i++)
cin>>a[i];
ans=b;
for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (a[j] > a[i])
        ans = max(ans, b % a[i] + b / a[i] * a[j]);

    }

}
cout<<ans;
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main ()
{
int n,b,a[2000],ans=0,x;
cin>>n>>b;
for(int i=0;i<n;i++)
cin>>a[i];

for(int i=0;i<n-1;i++)
{if(a[i]<a[i+1])
{x=b/a[i];
ans+=a[i+1]*x-a[i]*x;
b+=ans;
}

}
cout<<b;
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main ()
{
int n,b,a[2000],ans=0,x;
cin>>n>>b;
for(int i=0;i<n;i++)
cin>>a[i];
ans=b;
for (int i = 0; i < n; ++i) {cout<<ans<<endl;
    for (int j = i + 1; j < n; ++j) {
      if (a[j] > a[i])
        ans = max(ans, b % a[i] + b / a[i] * a[j]);

    }

}
cout<<ans;
return 0;
}


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

int main()
{
    int n,m,i=0,ma=0,a[2002];
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int j=i;j>=0;j--)
    {
        for(int k=j-1,p;k>=0;k--)
        {
            p=a[j]-a[k];
            if(p>0)
            {
                if( (((int)(m/a[k]))*p) >ma)
                    ma=(((int)(m/a[k]))*p);
            }
        }
    }
    cout<<m+ma;
    //system("pause");
    return 0;
}


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

int main()
{
    int n,m,i=0,ma=0,a[2002];
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int j=i-1;j>=0;j--)
    {
        for(int k=j-1,p;k>=0;k--)
        {
            p=a[j]-a[k];
            if(p>0)
            {
                if( (((int)(m/a[k]))*p) >ma)
                    ma=(((int)(m/a[k]))*p);
            }
        }
    }
    cout<<m+ma;
    //system("pause");
    return 0;
}


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

int main()
{
    int n,m,i=0,ma=0,a[2002];
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int j=i;j>=0;j--)
    {
        for(int k=j-1,p;k>=0;k--)
        {
            p=a[j]-a[k];
            if(p>0)
            {
                if(m/a[k]*p>ma)
                    ma=m/a[k]*p;
            }
        }
    }
    cout<<m+ma;
    //system("pause");
    return 0;
}


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

int main(){
	vector<int> a;
	int n;
	int b;
	cin >> n >> b;
	int i,j;

	for (i = 0; i < n; i++){
		int temp;
		cin >> temp;
		a.push_back(temp);
	}
	int t=0;
	int ans = 0;
	for (i = 0; i < n; i++){
		int f0 = -1;
		for (j = i + 1; j<n; j++){
			if (a[j]>a[i]){
				if (f0 == -1){
					t = a[j];
					f0 = 0;
				}
				else
					t = max(t, a[j]);
			}

		}
		if (f0 == -1)continue;
		int rec = b;
		b = b / a[i]*t + b%a[i];
		ans = max(b, ans);
		b = rec;

	}
	cout << ans<< endl;
//	system("pause");
	return 0;
}


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

int main(){
	vector<int> a;
	int n;
	int b;
	cin >> n >> b;
	int i,j;

	for (i = 0; i < n; i++){
		int temp;
		cin >> temp;
		a.push_back(temp);
	}
	int t=0;
	int ans = b;
	for (i = 0; i < n; i++){
		int f0 = -1;
		for (j = i + 1; j<n; j++){
			if (a[j]>a[i]){
				if (f0 == -1){
					t = a[j];
					f0 = 0;
				}
				else
					t = max(t, a[j]);
			}

		}
		if (f0 == -1)continue;
		int rec = b;
		b = b / a[i]*t + b%a[i];
		ans = max(b, ans);
		b = rec;

	}
	cout << ans<< endl;
	//system("pause");
	return 0;
}


#include <iostream>
using namespace std;

#define min(x,y) x>y?y:x
#define max(x,y) x>y?x:y
int main(){
	//int a;
	int n, b,res;
	cin >> n >> b;
	int minv = (1 << 31) - 1;
	res = 0;
	for (int i = 0; i < n; ++i){
		int a;
		cin >> a;
		minv = min(minv, a);
		int r = b / minv*a + b%minv;
		res = max(r, res);
	}
	cout << res;
	//vector<int> a;
	//int n;
	//int b;
	//cin >> n >> b;
	//int i,j;
	//
	//for (i = 0; i < n; i++){
	//	int temp;
	//	cin >> temp;
	//	a.push_back(temp);
	//}
	//int t=0;
	//int ans = b;
	//for (i = 0; i < n; i++){
	//	int f0 = -1;
	//	for (j = i + 1; j<n; j++){
	//		if (a[j]>a[i]){
	//			if (f0 == -1){
	//				t = a[j];
	//				f0 = 0;
	//			}
	//			else
	//				t = max(t, a[j]);
	//		}
	//
	//	}
	//	if (f0 == -1)continue;
	//	int rec = b;
	//	b = b / a[i]*t + b%a[i];
	//	ans = max(b, ans);
	//	b = rec;

	//}
	//cout << ans<< endl;
	//system("pause");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=3100;
int n,p,a[N],maxx;
int main()
{
	scanf("%d%d",&n,&p);maxx=p;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) maxx=max(maxx,p%a[i]+(p/a[i]*a[j]));
	printf("%d\n",maxx);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=1100;
int n,p,a[N],maxx;
int main()
{
	scanf("%d%d",&n,&p);maxx=p;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) maxx=max(maxx,p%a[i]+(p/a[i]*a[j]));
	printf("%d\n",maxx);
	return 0;
}


#include <iostream>
#include <cmath>
#include <stack>
using namespace std;
int main() {
    int n, b, i, j, o = 0, a[2001];
    cin >> n >> b;
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (i = 0; i < n; i++) {
        for (j = 0; j < i; j++) {
            if (a[i] > a[j]) {
                if (b / a[j] * (a[i] - a[j]) > o) {
                    o = b / a[j] * (a[i] - a[j]);
                }
            }
        }
    }
    cout << o + b;
}


#include <iostream>
#include <cmath>
#include <stack>
using namespace std;
int main() {
    int n, b, i, j, m = 0, p = 0, a[2001];
    cin >> n >> b;
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (i = n - 1; i >= 0; i--) {
        for (j = i - 1; j >= 0; j--) {
            if (a[i] - a[j] > m) {
                m = a[i] - a[j];
            }
            if (b + (b / a[j]) * m > p) p = b + (b / a[j]) * m;
        }
    }
    cout << p;
}


#include <iostream>
#include <cmath>
#include <stack>
using namespace std;
int main() {
    int n, b, i, j, m = 0, o = 0, a[2001];
    cin >> n >> b;
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (i = n - 1; i >= 0; i--) {
        for (j = i - 1; j >= 0; j--) {
            if (a[i] - a[j] > m) {
                m = a[i] - a[j];
                o = j;
            }
        }
    }
    cout << b + (b / a[o]) * m;
}


#include<bits/stdc++.h>
#define HURRY_UP ios_base::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr);

using namespace std;
int n , b;
int a[2005];

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

int Solve(void);

int main()
{
    HURRY_UP;
    Read();
    Solve();
    return 0;
}

int Solve(void)
{
    int MX = b;
    for(int i = 0 ; i < n - 1 ; ++i){
        int Buy = (b / a[i]) ;
        int Rem = (b % a[i]) ;
        for(int j = i + 1 ; j < n ; ++j){
            MX = max (MX , Buy * a[j] + Rem);
        }
    }
        return cout << MX << '\n', 0;
}


import java.util.*
import kotlin.math.max

fun main(vararg args: String) {

    var (N, b) = readLine()!!.split(' ').map(String::toInt)
    var aa = readLine()!!.split(' ').map { it.toInt() }
    var a = aa.toMutableList().apply { add(0) }.toIntArray()

    var MX = b
    for (i in 0 until (a.size -2)) {
        var Buy = (b / a[i])
        var Rem = (b % a[i])
        for (j  in (i + 1).rangeTo(a.size-1) ) {
            MX = max(MX , Buy * a[j] + Rem)
        }
    }
    println(MX)

}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef long double ldouble;

const int N=2010;

int P[N], L[N], memo[N][N];

int dp(int n, int m) {
	int &ans=memo[n][m];
	if (ans!=-1) return ans;
	if (!m) return ans=0;
	if (!n) return ans=m;
	ans=dp(n-1, m);
	if (m>=P[n]) ans=max(ans, dp(n, m-P[n])+L[n]);
	return ans;
}

int main() {
	int n, b;
	scanf("%d %d", &n, &b);
	for (int i=1; i<=n; i++) scanf("%d", &P[i]);
	for (int i=1; i<=n; i++) {
		L[i]=P[i];
		for (int j=i+1; j<=n; j++) L[i]=max(L[i], P[j]);
	}
	memset(memo, -1, sizeof(memo));
	printf("%d\n", dp(n, b));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef long double ldouble;

const int N=2010;

int P[N];
int main() {
	int n, b;
	scanf("%d %d", &n, &b);
	for (int i=1; i<=n; i++) scanf("%d", &P[i]);
	int ans=0;
	for (int i=1; i<=n; i++) {
		int mini=P[i];
		for (int j=1; j<i; j++) mini=min(mini, P[j]);
		ans=max(ans, b/mini*P[i]+b%mini);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main() {

	int n, m;
	cin >> n >> m;
	vector<int> y(n);

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

	bool buy = true;
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j){
			int dol = 0;
			int t = m;
			if (y[i] < y[j] && m / (float) y[i] >= 1 && i != n - 1) {
				dol = t / y[i];
				t = t % y[i];
				if (t + dol * y[j] > sum)
					sum = t + dol * y[j];
			}
		}

	}
	cout << sum;
	return 0;
}


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

int main() {

	int n, m;
	cin >> n >> m;
	vector<int> y(n);

	for (int i = 0; i < n; ++i) {
		cin >> y[i];
	}
	int dol = 0;
	bool buy = true;
	for (int i = 0; i < n; ++i) {

		if (y[i] < y[i - 1] && i != 0) {
			buy = true;
			m = m + y[i - 1] * dol;
			dol = 0;
		}
		if (y[i] < y[i + 1] && buy && m / (float) y[i] >= 1 && i != n-1) {
			dol += m / y[i];
			m = m % y[i];
			buy = false;
		}

	}
	m += dol * y[n - 1];
	cout << m;
	return 0;
}


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

int main() {

	int n, m;
	cin >> n >> m;
	vector<int> y(n);

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

	bool buy = true;
	int sum = m;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j){
			int dol = 0;
			int t = m;
			if (y[i] < y[j] && m / (float) y[i] >= 1 && i != n - 1) {
				dol = t / y[i];
				t = t % y[i];
				if (t + dol * y[j] > sum)
					sum = t + dol * y[j];
			}
		}

	}
	cout << sum;
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define SZ(X) (int)(X).size()
#define pb(X) push_back(X)
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define pi 3.1415926536
#define ll long long
const double EPS = 1e-9;
const int inf = 1 << 30;

ll pw(ll b, ll p)
{
    if (!p) return 1;
    ll sq = pw(b, p / 2);
    sq *= sq;
    if (p % 2) sq *= b;
    return sq;
}
ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
ll sd(ll x)
{
    return x<10 ? x : x % 10 + sd(x / 10);
}
ll lcm(ll a, ll b)
{
    return ((a*b) / gcd(a, b));
}
int len_of_number(ll n)
{
    ll temp = n;
    int cnt = 0;
    while(temp)
    {
        cnt++;
        temp/=10;
    }
    return cnt;
}
ll cnt[100002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, b, remain, profit;
    cin>>n>>b;
    int ar[n+1], maxi = b;
    for(int i = 0 ; i < n ; i++)
        cin>>ar[i];

    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] > b)
            continue;
        remain = b - ((b/ar[i])*ar[i]);
        for(int j = i ; j < n ; j++)
        {
            profit = remain + ((b/ar[i])*ar[j]);
            cout<<profit<<endl;
            maxi = max(profit, maxi);
        }
    }
    cout<<maxi;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define SZ(X) (int)(X).size()
#define pb(X) push_back(X)
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define pi 3.1415926536
#define ll long long
const double EPS = 1e-9;
const int inf = 1 << 30;

ll pw(ll b, ll p)
{
    if (!p) return 1;
    ll sq = pw(b, p / 2);
    sq *= sq;
    if (p % 2) sq *= b;
    return sq;
}
ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
ll sd(ll x)
{
    return x<10 ? x : x % 10 + sd(x / 10);
}
ll lcm(ll a, ll b)
{
    return ((a*b) / gcd(a, b));
}
int len_of_number(ll n)
{
    ll temp = n;
    int cnt = 0;
    while(temp)
    {
        cnt++;
        temp/=10;
    }
    return cnt;
}
ll cnt[100002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, b, canbuy, remain, profit, maxi = 0;
    cin>>n>>b;
    int ar[n+1];
    for(int i = 0 ; i < n ; i++)
        cin>>ar[i];

    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] > b)
            continue;
        canbuy = ((b/ar[i]));
        remain = b%ar[i];
        for(int j = i ; j < n ; j++)
        {
            profit = canbuy*ar[j] + remain;
            maxi = max(profit, maxi);
        }
    }
    cout<<maxi;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define SZ(X) (int)(X).size()
#define pb(X) push_back(X)
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define pi 3.1415926536
#define ll long long
const double EPS = 1e-9;
const int inf = 1 << 30;

ll pw(ll b, ll p)
{
    if (!p) return 1;
    ll sq = pw(b, p / 2);
    sq *= sq;
    if (p % 2) sq *= b;
    return sq;
}
ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
ll sd(ll x)
{
    return x<10 ? x : x % 10 + sd(x / 10);
}
ll lcm(ll a, ll b)
{
    return ((a*b) / gcd(a, b));
}
int len_of_number(ll n)
{
    ll temp = n;
    int cnt = 0;
    while(temp)
    {
        cnt++;
        temp/=10;
    }
    return cnt;
}
ll cnt[100002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, b, remain, profit, maxi = 0;
    cin>>n>>b;
    int ar[n+1];
    for(int i = 0 ; i < n ; i++)
        cin>>ar[i];

    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] > b)
            continue;
        remain = b - ((b/ar[i])*ar[i]);
        for(int j = i ; j < n ; j++)
        {
            profit = remain + ((b/ar[i])*ar[j]);
            maxi = max(profit, maxi);
        }
    }
    cout<<maxi;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define SZ(X) (int)(X).size()
#define pb(X) push_back(X)
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define pi 3.1415926536
#define ll long long
const double EPS = 1e-9;
const int inf = 1 << 30;

ll pw(ll b, ll p)
{
    if (!p) return 1;
    ll sq = pw(b, p / 2);
    sq *= sq;
    if (p % 2) sq *= b;
    return sq;
}
ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
ll sd(ll x)
{
    return x<10 ? x : x % 10 + sd(x / 10);
}
ll lcm(ll a, ll b)
{
    return ((a*b) / gcd(a, b));
}
int len_of_number(ll n)
{
    ll temp = n;
    int cnt = 0;
    while(temp)
    {
        cnt++;
        temp/=10;
    }
    return cnt;
}
ll cnt[100002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, b, canbuy, remain, profit;
    cin>>n>>b;
    int ar[n+1], maxi = b;
    for(int i = 0 ; i < n ; i++)
        cin>>ar[i];

    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] > b)
            continue;
        canbuy = ((b/ar[i]));
        remain = b%ar[i];
        for(int j = i ; j < n ; j++)
        {
            profit = canbuy*ar[j] + remain;
            maxi = max(profit, maxi);
        }
    }
    cout<<maxi;
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define SZ(X) (int)(X).size()
#define pb(X) push_back(X)
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define pi 3.1415926536
#define ll long long
const double EPS = 1e-9;
const int inf = 1 << 30;

ll pw(ll b, ll p)
{
    if (!p) return 1;
    ll sq = pw(b, p / 2);
    sq *= sq;
    if (p % 2) sq *= b;
    return sq;
}
ll gcd(ll a, ll b)
{
    return (b == 0 ? a : gcd(b, a % b));
}
ll sd(ll x)
{
    return x<10 ? x : x % 10 + sd(x / 10);
}
ll lcm(ll a, ll b)
{
    return ((a*b) / gcd(a, b));
}
int len_of_number(ll n)
{
    ll temp = n;
    int cnt = 0;
    while(temp)
    {
        cnt++;
        temp/=10;
    }
    return cnt;
}
ll cnt[100002];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, b, remain, profit;
    cin>>n>>b;
    int ar[n+1], maxi = b;
    for(int i = 0 ; i < n ; i++)
        cin>>ar[i];

    for(int i = 0 ; i < n ; i++)
    {
        if(ar[i] > b)
            continue;
        remain = b - ((b/ar[i])*ar[i]);
        for(int j = i ; j < n ; j++)
        {
            profit = remain + ((b/ar[i])*ar[j]);
            maxi = max(profit, maxi);
        }
    }
    cout<<maxi;
    return 0;
}


#include <iostream>
#include<fstream>
using namespace std;
int main(){
    int n;
    int m;
    vector<int>v(n);
    cin >> n >> m;
    for(int i = 0; i < n ; i++)
        cin >> v[i];
    vector<int>tmp;
    int ans = 0;
    tmp.push_back(v[0]);
    for(int i = 1 ; i < n ; i++){
        if(v[i]<=tmp.back())
            tmp.back()
        else
            tmp.push_back(v[i]);
    }
    for(int i = 1 ; i < tmp.size();i++){
        int rec=m/tmp[i-1];
        m = m - (rec * tmp[i-1]) + (rec * tmp[i]);
    }
    cout << m << endl;

}


#include <iostream>
#include<fstream>
#include <vector>
using namespace std;
int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int>v(n);
    for(int i = 0; i < n ; i++)
        cin >> v[i];
    int ret = m ;
    for(int i = 0; i < n ; i++){
        for(int j = i+1;j<n;j++){
            ret = max(ret,m/v[i] * v[j] + m %v[i]);
        }
    }
    cout << ret << endl;
}


#include <iostream>
#include<fstream>
#include <vector>
using namespace std;
int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int>v(n);
    for(int i = 0; i < n ; i++)
        cin >> v[i];
    vector<int>tmp;
    int ans = 0;
    tmp.push_back(v[0]);
    for(int i = 1 ; i < n ; i++){
        if(v[i]<=tmp.back())
            tmp.back();
        else
            tmp.push_back(v[i]);
    }
    for(int i = 1 ; i < tmp.size();i++){
        int rec=m/tmp[i-1];
        m = m - (rec * tmp[i-1]) + (rec * tmp[i]);
    }
    cout << m << endl;

}


#include <iostream>
#include<fstream>
#include <vector>
using namespace std;
int main(){
    int n;
    int m;
    vector<int>v(n);
    cin >> n >> m;
    for(int i = 0; i < n ; i++)
        cin >> v[i];
    vector<int>tmp;
    int ans = 0;
    tmp.push_back(v[0]);
    for(int i = 1 ; i < n ; i++){
        if(v[i]<=tmp.back())
            tmp.back();
        else
            tmp.push_back(v[i]);
    }
    for(int i = 1 ; i < tmp.size();i++){
        int rec=m/tmp[i-1];
        m = m - (rec * tmp[i-1]) + (rec * tmp[i]);
    }
    cout << m << endl;

}


#include <iostream>
#include<fstream>
#include <vector>
using namespace std;
int main(){
    int n;
    int m;
    cin >> n >> m;
    vector<int>v(n);
    for(int i = 0; i < n ; i++)
        cin >> v[i];
    vector<int>tmp;
    int ans = 0;
    tmp.push_back(v[0]);
    for(int i = 1 ; i < n ; i++){
        if(v[i]<=tmp.back())
            tmp.back() = v[i];
        else
            tmp.push_back(v[i]);
    }
    for(int i = 1 ; i < tmp.size();i++){
        int rec=m/tmp[i-1];
        m = m - (rec * tmp[i-1]) + (rec * tmp[i]);
    }
    cout << m << endl;

}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=(s); i<(e); i++)

int main(){
    int n, b;
    cin>>n>>b;
    int a[n];
    FOR(i,0,n) cin>>a[i];
    int dif=0;
    int buy, sell;
    int ans;
    FOR(i,0,n){
        FOR(j,i,n){
            if(a[j]-a[i]> dif && a[i]<=b){
                dif=a[j]-a[i];
                buy=a[i];
                sell=a[j];
            }
        }
    }
    if(dif==0) ans=b;
    else{
        ans=b%buy + (b/buy)*sell;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=(s); i<(e); i++)
#define LL long long

int main(){
    int n, b;
    cin>>n>>b;
    int a[n];
    FOR(i,0,n) cin>>a[i];
    LL dif=0;
    LL buy, sell;
    LL ans;
    FOR(i,0,n){
        FOR(j,i,n){
            if(a[j]-a[i]> dif && a[i]<=b){
                dif=a[j]-a[i];
                buy=a[i];
                sell=a[j];
            }
        }
    }
    if(dif==0) ans=b;
    else{
        ans=b%buy + (b/buy)*sell;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i=(s); i<(e); i++)
#define LL long long

int main(){
    LL n, b;
    cin>>n>>b;
    int a[n];
    FOR(i,0,n) cin>>a[i];
    LL ans=b;
    FOR(i,0,n){
        FOR(j,i+1,n){
           ans=max(ans,b%a[i] + (b/a[i])*a[j]);
        }
    }
    cout<<ans;
    return 0;
}


///BISMILLAHIR RAHMANIR RAHIM///
///******ASIFUR RAHMAN******///
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll d,n,i,j,sum,b;
    while(cin>>n>>b){
        ll a[n+1];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll min_p=a[0],max_p=a[0];
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(a[j]>a[i])
                    if(a[i]<=min_p)
                    {
                        min_p=a[i];
                        max_p=a[j];
                    }
                }
           }
        //cout<<min_p<<" "<<max_p<<endl;
        ll buy=b/min_p;
        sum=b%min_p;
        ll sell=buy*max_p;
        //cout<<buy<<" "<<sum<<" "<<sell<<endl;
        sum+=sell;
        cout<<sum<<endl;
    }
    return 0;
}


///BISMILLAHIR RAHMANIR RAHIM///
///******ASIFUR RAHMAN******///
#include<bits/stdc++.h>
#define ll long long
ll tk;
ll check(ll b,ll s){
     ll res=((tk/b)*s)+(tk%b);
     return res;
}
using namespace std;
int main()
{
    ll n,i,j;
    while(cin>>n>>tk){
        ll a[n+1];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll ans=tk;
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(a[j]>a[i]){
                ans=max(ans,check(a[i],a[j]));
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


///BISMILLAHIR RAHMANIR RAHIM///
///******ASIFUR RAHMAN******///
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll d,n,i,j,sum,b;
    while(cin>>n>>b){
        ll a[n+1];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll df=0,mx=0,max_p=a[0],min_p=a[0];
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(a[j]>a[i]){
                        df=a[j]-a[i];
                        if(df>=mx && min_p>=a[j]){
                           mx=df;
                           min_p=a[i];
                           max_p=a[j];

                     }
                }
           }

        }
        //cout<<min_p<<" "<<max_p<<endl;
        ll buy=b/min_p;
        sum=b%min_p;
        ll sell=buy*max_p;
        //cout<<buy<<" "<<sum<<" "<<sell<<endl;
        sum+=sell;
        cout<<sum<<endl;
    }
    return 0;
}


///BISMILLAHIR RAHMANIR RAHIM///
///******ASIFUR RAHMAN******///
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll d,n,i,j,sum,b;
    while(cin>>n>>b){
        ll a[n+1];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll df=0,mx=0,max_p=a[0],min_p=a[0];
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(a[j]>a[i]){
                        df=a[j]-a[i];
                        if(df>=mx && min_p>=a[i]){
                           mx=df;
                           min_p=a[i];
                           max_p=a[j];

                     }
                }
           }

        }
        //cout<<min_p<<" "<<max_p<<endl;
        ll buy=b/min_p;
        sum=b%min_p;
        ll sell=buy*max_p;
        //cout<<buy<<" "<<sum<<" "<<sell<<endl;
        sum+=sell;
        cout<<sum<<endl;
    }
    return 0;
}


///BISMILLAHIR RAHMANIR RAHIM///
///******ASIFUR RAHMAN******///
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll d,n,i,j,sum,b;
    while(cin>>n>>b){
        ll a[n+1];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll df=0,mx=0,max_p=a[0],min_p=a[0];
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
                if(a[j]>a[i]){
                        df=a[j]-a[i];
                        if(df>=mx){
                           mx=df;
                           min_p=a[i];
                           max_p=a[j];

                     }
                }
           }

        }
        //cout<<min_p<<" "<<max_p<<endl;
        ll buy=b/min_p;
        sum=b%min_p;
        ll sell=buy*max_p;
        //cout<<buy<<" "<<sum<<" "<<sell<<endl;
        sum+=sell;
        cout<<sum<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,j;
long long a [20000];
long long n,k,ans,cur;
int main () {
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    cin >> n >> k;
    for (i=0; i<n; i++) {
        cin >> a[i];
    }
    for (i=0; i<(n-1); i++) {
        for (j=i+1; j<n; j++) {
            cur = k/a[i];
            if ((k % a[i])+ (cur*a[j]) > ans) {
                ans =(k % a[i])+ (cur*a[j]);
            //cout << ans << ' ' << i << ' ' << a[i] << ' ' << j << ' ' << a[j] << endl;
            }

        }

    }
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
int i,j;
long long a [20000];
long long n,k,ans,cur;
int main () {
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    cin >> n >> k;
    for (i=0; i<n; i++) {
        cin >> a[i];
    }
    ans = k;
    for (i=0; i<(n-1); i++) {
        for (j=i+1; j<n; j++) {
            cur = k/a[i];
            if ((k % a[i])+ (cur*a[j]) > ans) {
                ans =(k % a[i])+ (cur*a[j]);
            //cout << ans << ' ' << i << ' ' << a[i] << ' ' << j << ' ' << a[j] << endl;
            }

        }

    }
    cout << ans;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int m;
int n;
int f[2542];
int a[2542];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);

    }
    f[0]=m;
    int ans=0;
    a[0]=1;
    for(int i=1;i<=n;i++)
    {
        f[i]=f[i-1];
        for(int j=1;j<i;j++)
         {
              f[i]=max(f[i],(int)f[j]/a[j]*a[i]+f[j]-a[j]*(int)(f[j]/a[j]));
         }
       //  printf("%d\n",f[i]);
    }

    printf("%d\n",f[n]);

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int m;
int n;
int f[2542];
int a[2542];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);

    }
    f[0]=m;
    int ans=0;
    a[0]=1;
    for(int i=2;i<=n;i++)
    {
        //f[i]=f[i-1];
        for(int j=1;j<i;j++)
         {
             // if(i==8)

              ans=max(ans,((int)(m/a[j]))*a[i]+m-a[j]*(int)(m/a[j]));
         }
      //   printf("**%d\n",f[i]);
    }

    printf("%d\n",ans);

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int m;
int n;
int f[2542];
int a[2542];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);

    }
    f[0]=m;
    int ans=m;
    a[0]=1;
    for(int i=2;i<=n;i++)
    {
        //f[i]=f[i-1];
        for(int j=1;j<i;j++)
         {
              ans=max(ans,((int)(m/a[j]))*a[i]+m-a[j]*(int)(m/a[j]));
         }
      //   printf("**%d\n",f[i]);
    }

    printf("%d\n",ans);

    return 0;
}


#include <bits/stdc++.h>
#include <new>
#include <string>

using namespace std;

const int m = 2 * 1000;

int a[m];
bool buy[m], sell[m];

bool IsThereSellBetween(int a, int b)
{
	while (a < b)
	{
		a++;

		if (sell[a])
			return 1;
	}
	return 0;
}

int main()
{
	int n, b, dollar = 0;

	cin >> n >> b;

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

	for(int i = 0; i < n; i++)
		if(a[i] < a[i + 1])
			buy[i] = 1;

	for(int i = 0; i < n; i++)
		if(a[i] > a[i + 1])
			sell[i] = 1;

	sell[n - 1] = 1;

	for(int i = 0; i < n; i++)
	{
		if (buy[i] && IsThereSellBetween(i, n))
		{
			dollar += b / a[i];

			b -= dollar * a[i];
		}
		else if (sell[i])
		{
			b += dollar * a[i];

			dollar = 0;
		}

		cerr << "Dollar : " << dollar << '\n' << "money : " << b << "\n\n\n";
	}

	cout << b;

	return 0;
}


#include <iostream>
#include <string>
#include <conio.h>

using namespace std;

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

    int a[n+1] , mx = b ;

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

        for ( int j = 1 ; j < i ; j++ )
            if ( a[i] > a[j] )
            {
                int res = ( b / a[j] ) * a[i] + ( b % a[j] ) ;

                if ( res > mx  )
                    mx = res ;
            }
    }

    cout << mx  << '\n';

    return 0 ;
}


#include <bits/stdc++.h>

using namespace std;

const int m = 2 * 1000;

int price[m];
bool buy[m], sell[m];

int main()
{
	int n, money, dollar = 0;

	cin >> n >> money;

	for (int i = 0; i < n; i++)
		cin >> price[i];

	for(int i = 0; i < n; i++)
		if(price[i] < price[i + 1] && (price[i] <= price[i - 1] || i == 0))
			buy[i] = 1;

	for(int i = 0; i < n; i++)
		if(price[i] > price[i + 1])
			sell[i] = 1;

	sell[n - 1] = 1;

	for(int i = 0; i < n; i++)
	{
		if (buy[i])
		{
			dollar += money / price[i];

			money -= dollar * price[i];
		}
		else if (sell[i])
		{
			money += dollar * price[i];

			dollar = 0;
		}

		cerr << "Dollar : " << dollar << '\n' << "money : " << money << "\n\n\n";
	}

	cout << money;

	return 0;
}


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

using namespace std;

const int m = 1000 * 1000 * 100;

bool mk[m];

int digcounter(int tmp)
	{
		int res = 0;

		while (tmp > 0)
		{
			res++;

			tmp /= 10;
		}

		return res;
	}

struct facts
{
	int num;

	bool* bl;

	facts ()
	{	}

	facts (int n)
	{
		num = n;
		bl = new bool[digcounter(n)];
	}

};

int main()
{
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int m = 2 * 1000;

int price[m];
bool buy[m], sell[m];

int main()
{
	int n, money, dollar = 0;

	cin >> n >> money;

	for (int i = 0; i < n; i++)
		cin >> price[i];

	for(int i = 0; i < n; i++)
		if(price[i] < price[i + 1] && (price[i] <= price[i - 1] || i == 0))
			buy[i] = 1;

	for(int i = 0; i < n; i++)
		if(price[i] > price[i + 1])
			sell[i] = 1;

	sell[n - 1] = 1;

	for(int i = 0; i < n; i++)
	{
		int buy_dollar;
		if (buy[i])
		{
			dollar += money / price[i];

			money -= dollar * price[i];
		}
		else if (sell[i])
		{
			money += dollar * price[i];

			dollar = 0;
		}

		cerr << "Dollar : " << dollar << '\n' << "money : " << money << "\n\n\n";
	}

	cout << money;

	return 0;
}


#include <bits/stdc++.h>
#include <new>
#include <string>

using namespace std;

const int m = 2 * 1000;

int a[m];
bool buy[m], sell[m];

int main()
{
	int n, b, dollar = 0;

	cin >> n >> b;

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

	for(int i = 0; i < n; i++)
		if(a[i] < a[i + 1])
			buy[i] = 1;

	for(int i = 0; i < n; i++)
		if(a[i] > a[i + 1])
			sell[i] = 1;

	sell[n - 1] = 1;

	for(int i = 0; i < n; i++)
	{
		if (buy[i])
		{
			dollar += b / a[i];

			b -= dollar * a[i];
		}
		else if (sell[i])
		{
			b += dollar * a[i];

			dollar = 0;
		}

//		cerr << "Dollar : " << dollar << '\n' << "money : " << b << "\n\n\n";
	}

	cout << b;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int m = 2 * 1000;

int price[m];
bool buy[m], sell[m];

int main()
{
	int n, money, dollar = 0;

	cin >> n >> money;

	for (int i = 0; i < n; i++)
		cin >> price[i];

	for(int i = 0; i < n; i++)
		if(price[i] < price[i + 1])
			buy[i] = 1;

	for(int i = 0; i < n; i++)
		if(price[i] > price[i + 1])
			sell[i] = 1;

	sell[n - 1] = 1;

	for(int i = 0; i < n; i++)
	{
		int buy_dollar;
		if (buy[i])
		{
			buy_dollar =  money / price[i];

			money -= buy_dollar * price[i];

			dollar += buy_dollar;
		}
		else if (sell[i])
		{
			money += dollar * price[i];

			dollar = 0;
		}

		cerr << "Dollar : " << dollar << '\n' << "money : " << money << "\n\n\n";
	}

	cout << money;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b,ans;
    cin>>a>>b;
    ans=b;
    int mx=0,check;
    int mn=20000;
    int alist[a];
    for(int i=0;i<a;i++){
        cin>>alist[i];

    }
    for(int i=0;i<a;i++){
        for(int j=i+1;j<a;j++)ans=max(ans,b%alist[i]+(b/alist[i])*alist[j]);
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    ll mx=0,check,mn=20000,alist[a],ans=b;
    for(int i=0;i<a;i++){
        cin>>alist[i];
        for(int j=0;j<i;j++)ans=max(ans,b%alist[j]+(b/alist[j])*alist[i]);
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    ll mx=0,check,mn=20000,alist[a],ans=b;
    for(int i=0;i<a;i++){
        cin>>alist[i];
        for(int j=0;j<i;j++)ans=max(ans,b%alist[i]+(b/alist[i])*alist[j]);
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    int mx=0,check;
    int mn=20000;
    int alist[a];
    for(int i=0;i<a;i++){
        cin>>alist[i];
        if(mx<=alist[i]){
            mx=alist[i];
            check=i;
        }

    }
    for(int i=0;i<check;i++){
        if(b>=alist[i] && alist[i]<mn)mn=alist[i];
    }
    cout<<max(b,b%mn+(b/mn)*mx);
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    int mx=0,check;
    int mn=20000;
    int alist[a];
    for(int i=0;i<a;i++){
        cin>>alist[i];

    }
    for(int i=0;i<a;i++){
        for(int j=i+1;j<a;j++)b=max(b,b%alist[i]+(b/alist[i])*alist[j]);
    }
    cout<<b;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
ll a,ans=0;
int alist[2500];
int DP(ll i, ll j,ll k){
    ans=max(j,ans);
    if(i>=a)return 0;

    if(k==0 && j>=alist[i])return max( DP(i+1,j%alist[i],j/alist[i]),DP(i+1,j,0));

    if(k!=0)return max( DP(i+1,j+(alist[i]*k) ,0),DP(i+1,j,k) );

    return DP(i+1,j,k);
}
int main(){
    ll b;
    cin>>a>>b;
    for(int i=0;i<a;i++)cin>>alist[i];
    DP(0,b,0);
    cout<<ans<<endl;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    int mx=0,check,mn=20000,alist[a],ans=b;
    for(int i=0;i<a;i++){
        cin>>alist[i];
        for(int j=0;j<i;j++)ans=max(ans,b%alist[i]+(b/alist[i])*alist[j]);
    }
    cout<<ans;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
int main(){
    ll a,b;
    cin>>a>>b;
    int mx=0,check;
    int mn=20000;
    int alist[a];
    for(int i=0;i<a;i++){
        cin>>alist[i];

    }
    for(int i=0;i<a;i++){
        for(int j=i+1;j<a;j++)b=max(b,b%alist[i]+(b/i)*alist[j]);
    }
    cout<<b;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long int
ll a,ans=0;
int alist[2500];
int DP(ll i, ll j,ll k){
    ans=max(j,ans);
    if(i>=a)return 0;

    if(k==0 && j>=alist[i])return max( DP(i+1,j%alist[i],j/alist[i]),DP(i+1,j,k));
    else if(k!=0)return max( DP(i+1,j+(alist[i]*k) ,0),DP(i+1,j,k) );
    else return DP(i+1,j,k);
}
int main(){
    ll b;
    cin>>a>>b;
    vector<pair<int,int>>vec;

    for(int i=0;i<a;i++)cin>>alist[i];
    DP(0,b,0);
    cout<<ans<<endl;
}


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define N 20001
#define rnt register int
using namespace std;
int n,m,ans,d[N];
inline int trade(int in,int out){
	int num=m/d[in];
	return m%d[in]+num*d[out];
}
int main(){
	scanf("%d%d",&n,&m);
	for(rnt i=1;i<=n;i=-~i) scanf("%d",&d[i]);
	for(rnt i=1;i<=n;i=-~i) for(rnt j=i;j<=n;j=-~j) ans=max(ans,trade(i,j));
	return printf("%d",ans),0;
}//17行代码你能秒我?


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define N 20001
#define rnt register int
using namespace std;
int n,m,ans,d[N];
inline int trade(int in,int out){
	int num=m/d[in];
	return m%d[in]+num*d[out];
}
int main(){
	scanf("%d%d",&n,&m);
	for(rnt i=1;i<=n;i=-~i) scanf("%d",&d[i]);
	for(rnt i=1;i<=n;i=-~i) for(rnt j=i;j<=n;j=-~j) ans=max(ans,trade(i,j));
	return printf("%d",ans);
}//17行代码你能秒我?


#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define N 2001
#define rnt register int
using namespace std;
int n,m,ans,d[N],f[N][N];
inline int trade(int in,int out){
	int num=m/d[in];
	return m%d[in]+num*d[out];
}
int main(){
	scanf("%d%d",&n,&m);
	for(rnt i=1;i<=n;i=-~i) scanf("%d",&d[i]);
	for(rnt i=1;i<=n;i=-~i) for(rnt j=i;j<=n;j=-~j) ans=max(ans,trade(i,j));
	return printf("%d",ans);
}//17行代码你能秒我?


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

int main()
{
    int n,b,a[2005],i,j,k;
    cin>>n>>b;
    for(i=1;i<=n;i++) cin>>a[i];
    int ans=b;
for(i=1;i<=n;i++){
        int temp;
        temp=b/a[i];
    for(j=i+1;j<=n;j++){
       int  temp1=temp*a[j];
       if(b+(temp1-(temp*a[i]))>ans)
       {
           ans=b+temp1-(temp*a[i]);
       }
    }
}
   cout<<ans<<endl;
}


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

int main()
{
    int n,b,a[2005],i,j,k;
    cin>>n>>b;
    for(i=1;i<=n;i++) cin>>a[i];
    int ans=b;
for(i=1;i<=n;i++){
        int temp;
        temp=b/a[i];
    for(j=i+1;j<=n;j++){
       int  temp1=temp*a[j];
       if(temp1-(temp*a[i])>0)
       {
           ans=b+temp1-(temp*a[i]);
       }
    }
}
   cout<<ans<<endl;
}


using System;

namespace Test
{
    class Program
    {
        static void Main()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            string[] arrMagnets = new string[n];
            int magnetsGroupCount = 1;
            for (int i = 0; i < n; i++)
            {
                arrMagnets[i] = Console.ReadLine();
            }

            char lastPoleType= arrMagnets[0][1];
            for (int i = 1; i < n; i++)
            {
                if(lastPoleType == arrMagnets[i][0])
                    magnetsGroupCount++;
                lastPoleType = arrMagnets[i][1];
            }

            Console.WriteLine(magnetsGroupCount);
        }
    }
}


using System;

namespace Test
{
    class Program
    {
        static void Main()
        {
            short n = Convert.ToInt16(Console.ReadLine());
            string[] arrMagnets = new string[n];
            short magnetsGroupCount = 1;
            for (short i = 0; i < n; i++)
            {
                arrMagnets[i] = Console.ReadLine();
            }

            char lastPoleType= arrMagnets[0][1];
            for (short i = 1; i < n; i++)
            {
                if(lastPoleType == arrMagnets[i][0])
                    magnetsGroupCount++;
                lastPoleType = arrMagnets[i][1];
            }

            Console.WriteLine(magnetsGroupCount);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            char ind_pr = Console.ReadLine()[1];
            int val = 1;
            for (int i = 1; i < n; i++)
            {
                char ind_la = Console.ReadLine()[0];
                if (ind_la == ind_pr)
                {
                    val++;
                    if (ind_la == '0') ind_pr = '1';
                    else ind_pr = '0';
                }
            }
            Console.WriteLine(val);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main(string[] args)
        {
            int n;
            n = Convert.ToInt32(Console.ReadLine());
            int hasil=0;
            String input="";
            String sementara="";
            for (int i = 0; i < n; i++)
            {
                input = Console.ReadLine();

                if (i == 0)
                {
                    sementara = input;
                    hasil++;
                }
                else if (sementara.Equals(input))
                {

                }
                else
                {
                    sementara = input;
                    hasil++;
                }

            }
            Console.WriteLine(hasil);
                Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int res = 0,
                inp = 0,
                tmp = 0;
            for (int i = 0; i < n; i++)
            {
                inp = int.Parse(Console.ReadLine());
                 if (inp != tmp)
                {
                    tmp = inp;
                    res++;
                }
            }

            Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}


using System;

namespace Olymp344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()), v = 1;
            string prev = string.Empty;
            for (int i = 0; i < n; ++i)
            {
                string input = Console.ReadLine();
                if (i != 0)
                    if (input != prev) ++v;
                prev = input;
            }
            Console.Write(v);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            Magnet[] magnets;
            int groupCount;

            n = Int32.Parse(Console.ReadLine());
            magnets = new Magnet[n];
            for (int i = 0; i < n; i++)
            {
                magnets[i] = new Magnet(Console.ReadLine());
            }

            groupCount = 1;
            for (int i = 1; i < magnets.Length; i++)
            {
                if (magnets[i].GetLeft == magnets[i - 1].GetRight)
                {
                    groupCount++;
                }
            }
            Console.WriteLine(groupCount);

            Console.ReadLine();
        }
    }

    class Magnet
    {
        public enum Type { P, N };

        Type left;
        Type right;

        public Magnet() : base()
        {
        }

        public Magnet(string inputString) : this()
        {
            char leftChar;
            char rightChar;

            if (inputString.Length != 2)
            {
                throw new Exception();
            }

            leftChar = inputString[0];
            rightChar = inputString[1];

            AssignPositivity(leftChar, ref left);
            AssignPositivity(rightChar, ref right);
        }

        private void AssignPositivity(char inputChar, ref Type side)
        {
            if (inputChar == '0')
            {
                side = Type.N;
            }
            else if (inputChar == '1')
            {
                side = Type.P;
            }
            else
            {
                throw new Exception();
            }
        }

        public Type GetLeft { get { return left; } }

        public Type GetRight { get { return right; } }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Olimp
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string str = ""; int K = 1;
            long N = long.Parse(Input);
            for (int i = 0; i < N; i++) {
                str += Console.ReadLine();
                if (i>=1 && str[str.Length - 2] == str[str.Length - 3]) K++;
            }
            Console.WriteLine(K);
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Olimp
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string str = "";
            long N = long.Parse(Input);
            for (int i = 0; i < N; i++ ) {
                str += Console.ReadLine();
            }
            str = str.Replace("11", "_"); str = str.Replace("00", "_");
            Console.WriteLine(str.Count<char>(s => s == '_') + 1);
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Olimp
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string str = ""; int K = 1;
            long N = long.Parse(Input);
            for (int i = 0; i < N; i++) {
                str += Console.ReadLine();
                if (i>1 && str[str.Length - 2] == str[str.Length - 3]) K++;
            }
            Console.WriteLine(K);
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Olimp
{
    class Program
    {
        static void Main(string[] args)
        {
            string Input = Console.ReadLine();
            string str = ""; int K = 1;
            long N = long.Parse(Input);
            for (int i = 0; i < N; i++) {
                str += Console.ReadLine();
                if (i>=1 && str[str.Length - 2] == str[str.Length - 3]) K++;
                if (i >= 1) str = str.Remove(0, 2);
            }
            Console.WriteLine(K);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int []arr=new int [n+1];
            int g = 0;
            for (int i = 1; i <= n; i++)
            {
                arr[i] = Convert.ToInt32(Console.ReadLine());
            }
            int d = arr.Distinct().Count();
            if (arr.Length % 2 == 0)
            {
                Console.WriteLine(arr.Length / 2);
            }
            else
            {
                Console.WriteLine(arr.Length / 2);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {

        static void Main(string[] args)
        {
          int n =Convert.ToInt32(Console.ReadLine());
            int i=0;
            int[] arr = new int[n+1];
            while(i<n){
                arr[i] = Convert.ToInt32(Console.ReadLine());
                i++;
            }
            int g = 1;
            int j = 0;
            while (j < n)
            {
                if (j == n-1)
                {
                    break;
                }

                    if (arr[j] != arr[j + 1])
                    {
                        g += 1;
                    }

                j++;
            }
            Console.WriteLine(g);
        }
    }
}


using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;

    public class Program
    {
        public static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            var magnet = new string[n];
            var count = 1;

            for (int i = 0; i < n; i++)
            {
                magnet[i] = Console.ReadLine();
            }
            for (int i = 0; i < n - 1; i++)
            {
                if (magnet[i] != magnet[i + 1])
                {
                    count++;
                }
            }

            Console.WriteLine(count);

        }
    }


using System;
using System.Linq;

namespace Codeforces
{
  class Program
  {
    static void Main(string[] args)
    {
      int n = Int32.Parse(Console.ReadLine());

      int c = 1;

      string last = Console.ReadLine();
      string current = String.Empty;
      n--;

      while (0 < n--)
      {
        current = Console.ReadLine();

        if (current[0] == last[1])
        {
          c++;
        }

        last = current;
      }

      Console.WriteLine(c);
    }
  }
}


using System;

namespace CodeForces
{
    public class Magnets
    {

        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        public static void Main ()
        {
            Magnets.Solve ();
        }

        private static void Solve ()
        {
            int n, prev = ' ', ans = 0;
            n = int.Parse (Console.ReadLine ());
            while (n-- > 0) {
                ans += (Console.Read () == prev) ? 1 : 0;
                prev = Console.Read ();
                Console.Read ();
            }

            Console.Write (ans + 1);
        }
    }
}


using System;
using System.IO;

namespace CodeForces
{
    public class Magnets
    {

        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        public static void Main ()
        {
            Magnets.Solve ();
        }

        private static void Solve ()
        {
            //input reader
            StreamReader reader = new StreamReader (Console.OpenStandardInput ());

            int n, ans = 0;
            char prev = ' ';
            n = int.Parse (reader.ReadLine ());
            while (n-- > 0) {
                ans += (reader.Read () != prev) ? 1 : 0;
                prev = (char)reader.Read ();
                reader.ReadLine ();
            }

            Console.WriteLine (ans - 1);
        }
    }
}


using System;

namespace CodeForces
{
    public class Magnets
    {

        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        public static void Main ()
        {
            Magnets.Solve ();
        }

        private static void Solve ()
        {
            int n, prev = ' ', ans = 0;
            n = int.Parse (Console.ReadLine ());
            while (n-- > 0) {
                ans += (Console.Read () == prev) ? 1 : 0;
                prev = Console.Read ();
                Magnets.ReadLine ();
            }

            Console.Write (ans + 1);
        }

        internal static void ReadLine ()
        {
            while (Console.Read() != '\n')
                ;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            char old =s[1];
            int sum = 0;
            for (int i = 0; i < n - 1; i++)
            {
                string omar = Console.ReadLine();
                if ( old == omar[0])
                {
                    sum++;
                    //Console.WriteLine(sum);
                }
                old = omar[1];
            }
            Console.WriteLine(sum+1);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces_344A_Magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int count = 1;
            string str1 = Console.ReadLine();
            string str2;
            for(int i=1;i<n;i++)
            {
                str2 = Console.ReadLine();
                if (str1 != str2)
                    count++;
                str1 = str2;
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces_344A_Magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int count = 1;
            string str1 = Console.ReadLine();
            string str2;
            for(int i=1;i<n;i++)
            {
                str2 = Console.ReadLine();
                if (str1 != str2)
                    count++;
                str1 = str2;
            }
            Console.WriteLine(count);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=int.Parse(Console.ReadLine());
            string[] m=new string[n];
            int g = 0;
            for (int i = 0; i < n; i++)
            {
                m[i] = Console.ReadLine();
            }
            for (int i = 0; i < m.Length-1; i++)
            {
                if(string.Compare(m[i],m[i+1])==0)
                {
                    continue;
                }
                else
                {
                    g++;
                }
            }
            Console.WriteLine(++g);

        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        private static void MyMain()
        {
            int n = RInt();

            string last = "";

            int counter = 0;
            for (int i = 0; i < n; i++)
            {
                string line = RLine();
                if (last != line)
                {
                    counter++;
                }
                last = line;
            }
            WLine(counter);
        }

        static void Main()
        {
#if !HOME
            MyMain();
#else
            var tmp = Console.In;
            Console.SetIn(new StreamReader("in.txt"));
            while (Console.In.Peek() > 0)
            {
                MyMain();
            }
            Console.In.Close();
            Console.SetIn(tmp);
            Console.ReadKey();
#endif
        }

        #region Utils
        static string RLine()
        {
            return Console.ReadLine();
        }

        static int RInt()
        {
            var str = Console.ReadLine();
            return Convert.ToInt32(str);
        }

        static int[] RInts()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));
        }

        static void RInts(out int a, out int b)
        {
            var ints = RInts();
            a = ints[0];
            b = ints[1];
        }

        static void WLine<T>(T s)
        {
            Console.WriteLine(s);
        }

        static void WYES()
        {
            WLine("YES");
        }

        static void WNO()
        {
            WLine("NO");
        }
        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication21
{
    class Program
    {
        static void Main(string[] args)
        {
            int u=0;
            int m = int.Parse(Console.ReadLine());
            int[] r = new int[m];
            for (int i = 0; i < m; i++)
            {
                r[i] = int.Parse(Console.ReadLine());

            }
            for (int i = 0; i < m-1; i++)
            {
                if (r[i] != r[i + 1]) u++;

            }
            Console.WriteLine(u + 1);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            char prev = s[1];
            int count = 1;
            for (int i=1;i<n;i++)
            {
                s = Console.ReadLine();
                if (s[0] == prev) count++;
                prev = s[1];
            }
            Console.Write(count);
         }
    }
}


using System;
using System.IO;
using System.Text;

namespace Magnets
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int n = Next();

            var nn = new int[n];
            for (int i = 0; i < n; i++)
            {
                nn[i] = Next();
            }

            int count = 1;
            for (int i = 1; i < n; i++)
            {
                if (nn[i] != nn[i - 1])
                {
                    count++;
                }
            }

            writer.WriteLine(count);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace magnets
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            int[] i = new int[n];
            int k,count=0;
            for(k=0;k<n;k++)
            {
                i[k] = Int32.Parse(Console.ReadLine());
            }
            for(k=1;k<n;k++)
            {
                if (i[k] == i[k - 1])
                    continue;
                else
                    count++;
            }
            Console.WriteLine(count + 1);
            Console.ReadLine();

        }
    }
}


using System;

namespace ConsoleApplication1
{
    internal class Program
    {
        private static string previous = String.Empty;
        private static string current = String.Empty;

        private static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var amt = 1;

            previous = Console.ReadLine();

            for (int i = 0; i < n-1; i++)
            {
                current = Console.ReadLine();

                if (current[0] == previous[1])
                    amt++;

                previous = current;
            }

            Console.WriteLine(amt);
        }
    }
}


using System;

namespace Number344A {
    class Program {
        static void Main(string[] args) {
            Int32 count = Int32.Parse(Console.ReadLine());
            String str = Console.ReadLine();
            Char curS = str[0];
            Int32 counter = 1;
            for(Int32 i = 1; i < count; i++) {
                str = Console.ReadLine();
                if(str[0] != curS) {
                    curS = str[0];
                    counter++;
                }
            }
            Console.WriteLine(counter);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _11
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=int.Parse(Console.ReadLine());
            int[]arr=new int[n];
            for (int i = 0; i < n; i++)
			{
                arr[i]=int.Parse(Console.ReadLine());

			}
            int c=1;
            for (int i = 0; i < n; i++)
			{
                if ((i + 1) == n)
                {

                    break;
                }
                else if (arr[i] != arr[i + 1])
                {
                    c = c + 1;
                }
                else
                    continue;

			}
            Console.WriteLine(c);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int count = 1;
            var arr = new int[n];
            for (int i = 0; i < n; i++)
                arr[i] = int.Parse(Console.ReadLine());
            for (int i = 0; i < n - 1; i++)
                if(arr[i] != arr[i + 1])
                {
                    count++;
                }
            Console.WriteLine(count);

        }
    }
}


using System;
using System.Linq;
using System.Windows.Markup;

namespace CF_344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            var vals = new bool[n];

            for (int i = 0; i < n; i++)
            {
                vals[i] = Console.ReadLine() == "10";
            }

            if (vals.All(x => x) || vals.All(x=>!x))
            {
                Console.WriteLine(1);
                return;
            }

            int cnt = 1;
            for (int j = 1; j < n; j++)
            {
                if (vals[j] != vals[j - 1]) cnt++;
            }

            Console.WriteLine(cnt);

        }
    }
}


using System;

namespace CF_344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            bool single = n == 1;

            bool? last = null;
            int cnt = 0;
            while (n>0)
            {
                bool cur = Console.ReadLine() == "10";
                if (last == null)
                {
                    last = cur;
                    continue;
                }

                if (cur == last) cnt++;

                last = cur;
                n--;
            }

            Console.WriteLine(single ? 1 : cnt);
        }
    }
}


using System;

namespace CF_344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            if(n==1) Console.WriteLine(1);

            bool? last = null;
            int cnt = 0;
            while (n>0)
            {
                bool cur = Console.ReadLine() == "10";
                if (last == null)
                {
                    last = cur;
                    continue;
                }

                if (cur == last) cnt++;

                last = cur;
                n--;
            }

            Console.WriteLine(cnt);
        }
    }
}


using System;

namespace CF_344A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            bool? last = null;
            int cnt = 0;
            while (n>0)
            {
                bool cur = Console.ReadLine() == "10";
                if (last == null)
                {
                    last = cur;
                    continue;
                }

                if (cur == last) cnt++;

                last = cur;
                n--;
            }

            Console.WriteLine(n == 1 ? 1 : cnt);
        }
    }
}