import java.util.*;
public class sol{
    public static void main(String[] args){
        Scanner console = new Scanner(System.in);
        int n = console.nextInt();
        double v = console.nextDouble();
        double[] a = new double[n];
        double[] b = new double[n];
        double total = 0;
        for ( int i = 0; i < n; i++ ){
            a[i] = console.nextDouble();
            total += a[i];
        }
        double[] check = new double[n];
        for ( int i = 0; i < n; i++ ){
            check[i] = a[i] / total;
        }
        for ( int i = 0; i < n; i++ )
        {
            b[i] = console.nextDouble();
        }
        double low = 0;
        double high = v;
        double curr = 0;
        boolean tooHigh = false;
        while ( low <= high )
        {
            double mid = low + ( high - low ) / 2;
            for ( int i = 0; i < n; i++ )
            {
                if ( check[i] * mid > b[i] ){
                    high = mid - 1;
                    tooHigh = true;
                    break;
                }
            }
            if ( !tooHigh ){
                low = mid + 1;
                curr = mid;
            }
        }
        System.out.println(curr);
    }
}


import java.util.*;
public class sol{
    public static void main(String[] args){
        Scanner console = new Scanner(System.in);
        int n = console.nextInt();
        int v = console.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int total = 0;
        for ( int i = 0; i < n; i++ ){
            a[i] = console.nextInt();
            total += a[i];
        }
        double[] check = new double[n];
        for ( int i = 0; i < n; i++ ){
            check[i] = (double) a[i] / total;
        }
        for ( int i = 0; i < n; i++ )
        {
            b[i] = console.nextInt();
        }
        double low = 0.00;
        double high = v;
        double curr = 0.00;
        boolean tooHigh = false;
        while ( low <= high )
        {
            double mid = low + ( high - low ) / 2;
            for ( int i = 0; i < n; i++ )
            {
                if ( check[i] * mid > b[i] ){
                    high = mid - 1;
                    tooHigh = true;
                    break;
                }
            }
            if ( !tooHigh ){
                low = mid + 1;
                curr = mid;
            }
            tooHigh = false;
        }
        System.out.println(curr);
    }
}


import java.util.*;
public class sol{
    public static void main(String[] args){
        Scanner console = new Scanner(System.in);
        int n = console.nextInt();
        int v = console.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int total = 0;
        for ( int i = 0; i < n; i++ ){
            a[i] = console.nextInt();
            total += a[i];
        }
        double[] check = new double[n];
        for ( int i = 0; i < n; i++ ){
            check[i] = (double) a[i] / total;
        }
        for ( int i = 0; i < n; i++ )
        {
            b[i] = console.nextInt();
        }
        double low = 0.00;
        double high = v;
        double curr = 0.00;
        boolean tooHigh = false;
        while ( low <= high )
        {
            double mid = low + ( high - low ) / 2;
            for ( int i = 0; i < n; i++ )
            {
                if ( check[i] * mid > b[i] ){
                    high = mid - 0.0001;
                    tooHigh = true;
                    break;
                }
            }
            if ( !tooHigh ){
                low = mid + 0.0001;
                curr = mid;
            }
            tooHigh = false;
        }
        System.out.println(curr);
    }
}


import java.util.*;
public class sol{
    public static void main(String[] args){
        Scanner console = new Scanner(System.in);
        int n = console.nextInt();
        int v = console.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int total = 0;
        for ( int i = 0; i < n; i++ ){
            a[i] = console.nextInt();
            total += a[i];
        }
        double[] check = new double[n];
        for ( int i = 0; i < n; i++ ){
            check[i] = (double) a[i] / total;
        }
        for ( int i = 0; i < n; i++ )
        {
            b[i] = console.nextInt();
        }
        double low = 0.00;
        double high = v;
        double curr = 0.00;
        boolean tooHigh = false;
        while ( low <= high )
        {
            double mid = low + ( high - low ) / 2;
            for ( int i = 0; i < n; i++ )
            {
                if ( check[i] * mid > b[i] ){
                    high = mid - 1;
                    tooHigh = true;
                    break;
                }
            }
            if ( !tooHigh ){
                low = mid + 1;
                curr = mid;
            }
        }
        System.out.println(curr);
    }
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=1e4+10;

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

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

	int b[n];
	double x=105;
	for (int i=0; i<n; i++){
		cin >> b[i];
		x = min(x, (double)b[i]/a[i]);
	}

	cout << fixed << setprecision(4) << min((double)v, double(x*sum)) << "\n";

	return 0;
}


#include <iostream>
#define ERROR 10e-5

using namespace std;
int a[101],b[101];
int main()
{
    int n,v;
    cin>>n>>v;

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

    double av = (double)b[0]/(double)a[0];

    for(int i =1;i<n;i++){
        if(av-(double)b[i]/(double)a[i]>ERROR){
            av = (double)b[i]/(double)a[i];
        }
    }

    double temp = 0;

    for(int i =0;i<n;i++){
        temp+=av*a[i];
    }
    if(temp-v>ERROR){
    temp = v;
    }

    cout<<temp;

    return 0;
}


#include <iostream>
#define ERROR 10e-5

using namespace std;

int main()
{
    int n,v;
    cin>>n>>v;
    int a[n],b[n];

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

    double av = (double)b[0]/(double)a[0];

    for(int i =1;i<n;i++){
        if(av-(double)b[i]/(double)a[i]){
            av = (double)b[i]/(double)a[i];
        }
    }

    double temp = 0;

    for(int i =0;i<n;i++){
        temp+=av*a[i];
    }
    if(temp-v>ERROR){
    temp = v;
    }

    cout<<temp;

    return 0;
}


#include <iostream>
#define ERROR 10e-5

using namespace std;

int main()
{
    int n,v;
    cin>>n>>v;
    int a[n],b[n];

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

    double av = (double)b[0]/(double)a[0];

    for(int i =0;i<n;i++){
        if(av-(double)b[i]/(double)a[i]){
            av = (double)b[i]/(double)a[i];
        }
    }

    double temp = 0;

    for(int i =0;i<n;i++){
        temp+=av*a[i];
    }
    if(temp-v>ERROR){
    temp = v;
    }

    cout<<temp;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pairs;
const ll MOD = 1e9+7, N = 1e6 + 1;

int main()
{
  ll n;
  ld v,sum=0,minn=1e10;
  cin>>n>>v;
  ld arr[n],brr[n];
  for(ll i=0;i<n;i++)
    {cin>>arr[i];sum=sum+arr[i];}
  for(ll i=0;i<n;i++)
  {
    cin>>brr[i];
    minn=min(minn,brr[i]/arr[i]);
  }
  ld temp=0;
  for(ll i=0;i<n;i++)
   temp=temp+arr[i]*minn;

 if(v>=temp)
 cout<<fixed<<setprecision(6)<<temp;
else
  cout<<fixed<<setprecision(6)<<v;

  return 0;
    }


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pairs;
const ll MOD = 1e9+7, N = 1e6 + 1;

int main()
{
  ll n;
  ld v,sum=0,minn=1e10;
  cin>>n>>v;
  ld arr[n],brr[n];
  for(ll i=0;i<n;i++)
    {cin>>arr[i];sum=sum+arr[i];}
  for(ll i=0;i<n;i++)
  {
    cin>>brr[i];
    minn=min(minn,brr[i]/arr[i]);
  }
  ld temp=0;
  for(ll i=0;i<n;i++)
   temp=temp+arr[i]*minn;

 while(temp>v)
 {
  temp=temp-sum;
 }
 cout<<fixed<<setprecision(6)<<temp;

  return 0;
    }


#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef string str;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vpl;

#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"

const int MOD = 998244353; // 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);
const int INFTY = 1e7;

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		ll n, V;
		cin >> n >> V;

		vector<ld> A(n), B(n);

		F0R(i, n) cin >> A[i];
		F0R(i, n) cin >> B[i];
		ld x = INF;

		for (int i = 0; i < n; i++) {
				ld rat = B[i]/A[i];
				x = MIN(rat, x);
		}
		ld ans = 0;
		for (int i = 0; i < n; i++) {
				ans += A[i] * x;
		}

		ans = MIN(ans, V);
		cout << fixed << setprecision(15) << ans << endl;
}


#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef string str;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll, ll>> vpl;

#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"

const int MOD = 998244353; // 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);
const int INFTY = 1e7;

int main() {
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		ll n, V;
		cin >> n >> V;

		vector<ld> A(n), B(n);

		F0R(i, n) cin >> A[i];
		F0R(i, n) cin >> B[i];
		ld mini = INF;

		for (int i = 0; i < n; i++) {
				ld rat = B[i]/A[i];
				mini = MIN(rat, mini);
		}

		mini = MIN(n * mini, V);
		cout << fixed << setprecision(15) << mini << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
   long double n,v,ans=2e9,temp,volume=0,a[201],b[201];
   int i,j,k;
   cin>>n>>v;
   for(i=0;i<n;i++){
      cin>>a[i];
   }
   for(i=0;i<n;i++){
      cin>>b[i];
   }
   for(i=0;i<n;i++){
      temp=b[i]/a[i];
      ans=min(temp,ans);
   }
   for(i=0;i<n;i++){
      volume+=ans*a[i];
   }
   cout<<setprecision(6)<<min(v,volume)<<endl;

}


#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, v;
	cin >> n >> v;
	double each = INT_MAX;
	double a[n], b[n], s = 0;
	for(int i = 0; i < n; i++) cin >> a[i], s+=a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) each = min(each, b[i]/a[i]);
	double ans = s * each;
	if(ans > v) ans = v;
	printf("%.4f\n", ans);
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, v;
	cin >> n >> v;
	double each = INT_MAX;
	double a[n], b[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	for(int i = 0; i < n; i++) each = min(each, b[i]/a[i]);
	double ans = n * each;
	if(ans > v) ans = v;
	printf("%.4f\n", ans);
	return 0;
}


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

int main() {
   ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
      #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    int n,v;
    cin>>n>>v;
    int a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int j=0;j<n;j++)cin>>b[j];
    double mn=INT_MAX;
    for(int i=0;i<n;i++)
    {
        mn=min(mn,b[i]/(1.0*a[i]));
    }
    printf("%.17lf",min(mn*n,v*1.0));
}


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

int main() {
   ios_base::sync_with_stdio(false);
      cin.tie(0);
      cout.tie(0);
      #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      #endif
    int n,v;
    cin>>n>>v;
    int a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int j=0;j<n;j++)cin>>b[j];
    double mn=INT_MAX;
    for(int i=0;i<n;i++)
    {
        mn=min(mn,b[i]/(1.0*a[i]));
    }
    int s=0;
    for(int i=0;i<n;i++)
    s+=a[i];
    printf("%.17lf",min(s*mn,v*(1.0)));
}


 #include<iostream>
#include<algorithm>
#include<vector>
#include<string>..
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<cstring>
#define DEBUG cout<<"DEBUG"
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 987654321;
const int max_n = 1e5 + 1;

int n, v;
double ans;
double a[21],b[21],rate[21];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> v;
	double mini = 101;
	int index = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

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

		if (mini > b[i] / a[i])
		{
			mini = b[i] / a[i];
			index = i;
		}
 	}
	double per = 0;
	for (int i = 1; i <= n; i++)
		per += a[i] / a[index];

	int cur = 0;
	while (cur<b[index]&& v-per>=0) {
		ans += per;
		cur++;
		v -= per;
	}
	cout << ans;
}


 #include<iostream>
#include<algorithm>
#include<vector>
#include<string>..
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<cstring>
#define DEBUG cout<<"DEBUG"
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 987654321;
const int max_n = 1e5 + 1;

int n, v;
double a[21];
double b[21];
double rate[21];
double ans;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cout.precision(4);

	cin >> n >> v;
	double mini = 101;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		mini = min(mini, a[i]);
	}
	double total = 0;
	for (int i = 1; i <= n; i++)
	{
		rate[i] = a[i]/mini; //가장 작은 값은 1이라고할때 필요한 재료들
		total += rate[i];
	}
	for (int i = 1; i <= n; i++)//필요한만큼의  b가 존재해야하고 모든 재료합을더하면 v보다 작아야만한다.
		cin >> b[i];
	bool stop = false;
 	while (true) {
		if (v - total < 0)stop=true;
		for (int i = 1; i <= n; i++)
		{
			b[i] -= rate[i];
			if (b[i] < 0.0)stop = true;
		}
		if (stop)break;

		v -= total;
		ans += total;
	}
	cout <<(double)ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>..
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<cstring>
#define DEBUG cout<<"DEBUG"
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 987654321;
const int max_n = 1e5 + 1;

int n, v;
double a[21];
double b[21];
double rate[21];
double ans;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cout.precision(4);

	cin >> n >> v;
	double mini = 101;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		mini = min(mini, a[i]);
	}
	double total = 0;
	for (int i = 1; i <= n; i++)
	{
		rate[i] = mini / a[i]; //가장 작은 값은 1이라고할때 필요한 재료들
		total += rate[i];
	}
	for (int i = 1; i <= n; i++)//필요한만큼의  b가 존재해야하고 모든 재료합을더하면 v보다 작아야만한다.
		cin >> b[i];
	bool stop = false;
 	while (true) {
		if (v - total < 0)stop=true;
		for (int i = 1; i <= n; i++)
		{
			b[i] -= rate[i];
			if (b[i] < 0.0)stop = true;
		}
		if (stop)break;

		v -= total;
		ans += total;
	}
	cout <<(double)ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>..
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<cstring>
#define DEBUG cout<<"DEBUG"
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 987654321;
const int max_n = 1e5 + 1;

int n, v;
double ans;
double a[21],b[21],rate[21];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> v;
	double mini = 101;
	int index = 0;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

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

		if (mini > b[i] / a[i])
		{
			mini = b[i] / a[i];
			index = i;
		}
 	}
	double per = 0;
	for (int i = 1; i <= n; i++)
		per += a[i] / a[index];

	int cur = 0;
	while (cur<b[index]&& v-per>=0) {
		ans += per;
		cur++;
	}
	cout << ans;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<string>..
#include<map>
#include<set>
#include<queue>
#include<string>
#include<string.h>
#include<cstring>
#define DEBUG cout<<"DEBUG"
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 987654321;
const int max_n = 1e5 + 1;

double n, v;
double ans;
double a[21],b[21],rate[21];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> v;

	double mini = 101;
	int index = 0;

	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++)   //가장 재료가 먼저 떨어져버리는 녀석을 단위 1로두고 빼가면 모든양을 1도남김없이 다쓸수가있음.
	{
		cin >> b[i];
		if (mini > b[i] / a[i])
		{
			mini = b[i] / a[i];
			index = i;
		}
 	}
	double per = 0;
	for (int i = 1; i <= n; i++)
		per += a[i] / a[index];

	double cur = 0;
	while (cur<b[index]) {
		ans += per;
		cur++;
	}
	cout.precision(15);
	cout <<min(v,ans);
}


/* created   : 2020-03-29 15:48:31
 * accepted  : 2020-03-29 16:00:13
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#ifndef LOCAL
#define trace(...)
#define xuyixuyi()
#endif
typedef long long ll;

void solve() {
  int n, v; cin >> n >> v;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  auto check = [&](double md) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] * md > b[i]) return false;
      sum += a[i] * md;
    }
    return sum < v;
  };
  trace(a, b);
  double lo = 0;
  double hi = 100;
  int cnt = 0;
  while (abs(hi - lo) > 1e-9) {
    cnt++;
    double md = (lo + hi) / 2;
    if ((check(md))) {
      lo = md;
    }
    else {
      hi = md;
    }
  }
  trace(cnt);
  double ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] * lo;
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(1);
  solve();
  return 0;
}


/* created   : 2020-03-29 15:48:31
 * accepted  : 2020-03-29 16:00:13
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#ifndef LOCAL
#define trace(...)
#define xuyixuyi()
#endif
typedef long long ll;

void solve() {
  int n, v; cin >> n >> v;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  auto check = [&](double md) {
    double sum = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] * md > b[i]) return false;
      sum += a[i] * md;
    }
    return sum < v;
  };
  trace(a, b);
  double lo = 0;
  double hi = 100;
  int cnt = 0;
  while (abs(hi - lo) > 1e-9) {
    cnt++;
    double md = (lo + hi) / 2;
    if ((check(md))) {
      lo = md;
    }
    else {
      hi = md;
    }
  }
  trace(cnt);
  double ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[i] * lo;
  }
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(20);
  solve();
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define INF 1000000000
#define forn(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define for1(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define pb push_back
#define ff first
#define ss second

int N, T, M, K;

int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
	int V;
	cin >> N >> V;
	vi a(N), b(N);
	forn(i, N) cin >> a[i];
	forn(i, N) cin >> b[i];
	int ratio = INF;
	forn(i, N){
		ratio = min(ratio, b[i]/a[i]);
	}
	int vol = 0;
	forn(i, N){
		vol += a[i] * ratio;
	}
	printf("%.4lf\n", min((double)V, (double)vol));
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
#define INF 1000000000
#define forn(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define for1(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define pb push_back
#define ff first
#define ss second

int N, T, M, K;

int main(){
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
	int V;
	cin >> N >> V;
	vi a(N), b(N);
	forn(i, N) cin >> a[i];
	forn(i, N) cin >> b[i];
	double ratio = INF;
	forn(i, N){
		ratio = min(ratio, (double)b[i]/(double)a[i]);
	}
	double vol = 0;
	forn(i, N){
		vol += (double)a[i] * ratio;
	}
	printf("%.9lf\n", min((double)V, (double)vol));
    return 0;
}


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

int main() {
	int n,v;
	cin>>n>>v;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	int k =0;
	float mi=INT_MAX;
	for(int i=0;i<n;i++)
	{
	    float j;
	    cin>>j;
	    k+=arr[i];
	    j/=arr[i];
	    mi = min(mi,j);
	}
	mi*=k;
	cout<<max(mi,v);
	return 0;
}


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

int main() {
	int n,v;
	cin>>n>>v;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	int k =0;
	float mi=INT_MAX;
	for(int i=0;i<n;i++)
	{
	    float j;
	    cin>>j;
	    k+=arr[i];
	    j/=arr[i];
	    mi = min(mi,j);
	}
	mi*=k;
	if(mi<=v)cout<<mi;
	else
	{
	    while(mi>v)
	    mi--;
	    cout<<mi;
	}
	return 0;
}


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

int main() {
	int n,v;
	cin>>n>>v;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	int k =0;
	float mi=INT_MAX;
	for(int i=0;i<n;i++)
	{
	    float j;
	    cin>>j;
	    k+=arr[i];
	    j/=arr[i];
	    mi = min(mi,j);
	}
	mi*=k;
if(mi>v)cout<<v;
else cout<<mi;
	return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define MP make_pair
#define dbg(x) cout << #x << ": " << x << endl
#define check(k, i, j) ((k>=i) && (k<=j))
#define ff first
#define ss second
#define all(x)  (x).begin(),(x).end()
#define rep0(i,n) for(int i=0;i<n;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;
using namespace std;
int dx[]={1,1,0,-1,-1,-1, 0, 1};
int dy[]={0,1,1, 1, 0,-1,-1,-1};

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

// ===================================== //

void solve(){
    double n, v;
    cin >> n >> v;
    vector<int> a(n), b(n);
    rep0(i, n){
        cin >> a[i];
    }
    rep0(i, n){
        cin >> b[i];
    }
    double m=100000;
    rep0(i, n){
        m = min(m, ((b[i]*1.0)/a[i]));
    }
    double sum=0;
    rep0(i, n){
        sum  += a[i]*m;
    }

    cout << fixed << setprecision(4) << min(v, sum) << endl;
}

int main(){

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    FAST_IO;
    int t=1;
    // cin >> t;
    while(t--){
        solve();
    }

    return 0;
}


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

#define loop(i, start, end) for(int i = start; i <= end; i++)
#define ll long long int
#define arrayInput(arr, n) loop(i, 0, n-1){ cin >> arr[i];}
#define arrayDisplay(arr, n) loop(i, 0, n-1){ cout << arr[i] << " ";}
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a, num) memset(a, num, sizeof(a))
#define vi vector<Int>
#define pb push_back
#define mp make_pair
#define sortva(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
double check(int n, double mid, int a[], int b[]){
    double sum = 0;
    loop(i, 0, n-1){
        if(a[i]*mid > b[i]){
            return INFINITY;
        }else{
            sum += a[i]*mid;
        }
    }
    return sum;
}
int main() {
    SPEED
    int t;
    t=1;
    while(t--){
        int n; double v; cin >> n >> v;
        int a[n]; arrayInput(a, n);
        int b[n]; arrayInput(b, n);
        double l = 0, r = v;
        double sum = 0, ans  =INT_MIN;
        while(abs(r-l) > 0.00001){
            double mid = l + (r-l)/2.0;
            sum = check(n, mid, a, b);
            if(sum <= v){
                ans = max(ans, sum);
                l = mid;
            }else{
                r = mid;
            }
        }
        cout << fixed << setprecision(4) << ans;
    }
    return 0;
}
/*
 _________________________
|       __                |
|  /\  |__) \ /  /\  |\ | |
| /~~\ |  \  |  /~~\ | \| |
|_________________________|

*/


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

#define loop(i, start, end) for(int i = start; i <= end; i++)
#define ll long long int
#define arrayInput(arr, n) loop(i, 0, n-1){ cin >> arr[i];}
#define arrayDisplay(arr, n) loop(i, 0, n-1){ cout << arr[i] << " ";}
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a, num) memset(a, num, sizeof(a))
#define vi vector<Int>
#define pb push_back
#define mp make_pair
#define sortva(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
bool check(int n, int v, int mid, int a[], int b[]){
    loop(i, 0, n-1){
        if(a[i]*mid > b[i]){
            return false;
        }
    }
    return true && (mid*n <= v);
}
int main() {
    SPEED
    int t;
    t=1;
    while(t--){
        int n; int v; cin >> n >> v;
        int a[n]; arrayInput(a, n);
        int b[n]; arrayInput(b, n);
        int l = 0, r = v;
        int ans = INT_MIN;
        while(l <= r){
            int mid = l + (r-l)/2;
            if(check(n, v, mid, a, b)){
                ans = max(mid, l);
                l = mid+1;
            }else{
                r = mid-1;
            }
        }
        float an = float(ans*n);
        cout << fixed << setprecision(4) << an;
    }
    return 0;
}
/*
 _________________________
|       __                |
|  /\  |__) \ /  /\  |\ | |
| /~~\ |  \  |  /~~\ | \| |
|_________________________|

*/


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

#define loop(i, start, end) for(int i = start; i <= end; i++)
#define ll long long int
#define arrayInput(arr, n) loop(i, 0, n-1){ cin >> arr[i];}
#define arrayDisplay(arr, n) loop(i, 0, n-1){ cout << arr[i] << " ";}
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a, num) memset(a, num, sizeof(a))
#define vi vector<Int>
#define pb push_back
#define mp make_pair
#define sortva(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
double check(int n, double mid, int a[], int b[]){
    double sum = 0;
    loop(i, 0, n-1){
        if(a[i]*mid > b[i]){
            return INFINITY;
        }else{
            sum += a[i]*mid;
        }
    }
    return sum;
}
int main() {
    SPEED
    int t;
    t=1;
    while(t--){
        int n; double v; cin >> n >> v;
        int a[n]; arrayInput(a, n);
        int b[n]; arrayInput(b, n);
        double l = 0, r = v;
        double sum = 0, ans = 0;
        while(abs(r-l) > 0.000001){
            double mid = l + (r-l)/2.0;
            sum = check(n, mid, a, b);
            if(sum <= v){
                ans = max(ans, sum);
                l = mid;
            }else{
                r = mid;
            }
        }
        cout << fixed << setprecision(4) << ans;
    }
    return 0;
}
/*
 _________________________
|       __                |
|  /\  |__) \ /  /\  |\ | |
| /~~\ |  \  |  /~~\ | \| |
|_________________________|

*/


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

#define loop(i, start, end) for(int i = start; i <= end; i++)
#define ll long long int
#define arrayInput(arr, n) loop(i, 0, n-1){ cin >> arr[i];}
#define arrayDisplay(arr, n) loop(i, 0, n-1){ cout << arr[i] << " ";}
#define SPEED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a, num) memset(a, num, sizeof(a))
#define vi vector<Int>
#define pb push_back
#define mp make_pair
#define sortva(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
double check(int n, double mid, int a[], int b[]){
    double sum = 0;
    loop(i, 0, n-1){
        if(a[i]*mid > b[i]){
            return INFINITY;
        }else{
            sum += a[i]*mid;
        }
    }
    return sum;
}
int main() {
    SPEED
    int t;
    t=1;
    while(t--){
        int n; double v; cin >> n >> v;
        int a[n]; arrayInput(a, n);
        int b[n]; arrayInput(b, n);
        double l = 0, r = v;
        double sum = 0, ans = 0;
        while(abs(r-l) > 0.00001){
            double mid = l + (r-l)/2.0;
            sum = check(n, mid, a, b);
            if(sum <= v){
                ans = max(ans, sum);
                l = mid;
            }else{
                r = mid;
            }
        }
        cout << fixed << setprecision(4) << ans;
    }
    return 0;
}
/*
 _________________________
|       __                |
|  /\  |__) \ /  /\  |\ | |
| /~~\ |  \  |  /~~\ | \| |
|_________________________|

*/


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0,v;
  cin >> n >> v;
  float a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%f",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%f",&b[i]);
    soto_ongso=(float)b[i]/(float)a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));

    sum+=b[i];
  }
  if(sum>v) printf("%.5f\n",v);
  else printf("%.5f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0,v;
  cin >> n >> v;
  float a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%f",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%f",&b[i]);
    soto_ongso=(float)b[i]/(float)a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {

    sum+=min*a[i];
  }
  if(sum>v) printf("%.1f\n",v);
  else printf("%.1f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0,v;
  cin >> n >> v;
  float a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%f",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%f",&b[i]);
    soto_ongso=(float)b[i]/(float)a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));

    sum+=b[i];
  }
  if(sum>v) printf("%.1f\n",v);
  else printf("%.1f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n,v;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0;
  cin >> n >> v;
  int a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%d",&b[i]);
    soto_ongso=(float)b[i]/a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));

    sum+=b[i];
  }
  if(sum>(float)v) printf("%.1f\n",v);
  else printf("%.1f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n,v;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0;
  cin >> n >> v;
  int a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%d",&b[i]);
    soto_ongso=(float)b[i]/a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));

    sum+=b[i];
  }
  if(sum>(float)v) printf("%d.0\n",v);
  else printf("%.1f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n,v;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0;
  cin >> n >> v;
  int a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%d",&b[i]);
    soto_ongso=(float)b[i]/a[i];
    if(min>soto_ongso)min=soto_ongso;
    //cout << min << endl;
  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));
    cout<< b[i] << endl;
    sum+=b[i];
  }
  if(sum>(float)v) printf("%.1f\n",v);
  else printf("%.1f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0,v;
  cin >> n >> v;
  float a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%f",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%f",&b[i]);
    soto_ongso=(float)b[i]/(float)a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {

    sum+=min*a[i];
  }
  if(sum>v) printf("%.5f\n",v);
  else printf("%.5f\n",sum);
}


#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
  int i,n;
  float soto_ongso,sum1=0.0,sum=0.0,min=10000.0,v;
  cin >> n >> v;
  float a[n],b[n];
  for(i=0;i<n;i++)
  {
    scanf("%f",&a[i]);
  }
  for(i=0;i<n;i++)
  {
    scanf("%f",&b[i]);
    soto_ongso=(float)b[i]/(float)a[i];
    if(min>soto_ongso)min=soto_ongso;

  }
  for(i=0;i<n;i++)
  {
    if(b[i]>(min*a[i]))b[i]=b[i]-(b[i]-(min*a[i]));

    sum+=b[i];
  }
  if(sum>v) printf("%.4f\n",v);
  else printf("%.4f\n",sum);
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,v;
    cin>>n>>v;
    int a[n],b[n],sum=0;
    double sm=1.0/0.0; //sm is small
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        if(b[i]/a[i]<sm)
        {
            sm=b[i]/a[i];
        }
    }
    if(v<(sum*sm))
    {
        cout<<v;
    }
    else{cout<<(sum*sm);}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double V;
    cin>>n>>V;
    double a[n],b[n],sum_a=0, minr=100000;//sum_a is the sum of A, minr is the minimum ratio
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        if(b[i]/a[i]<minr)
        {
            minr=b[i]/a[i];
        }
        sum_a+=a[i];
    }
    double e1=minr*sum_a; // e1 is the first estimate
    if(e1>V)
    {
        cout<<V;
    }
    else
    {
        cout<<e1;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,v;
    cin>>n>>v;
    double a[n],b[n],sum=0;
    double sm=1.0/0.0; //sm is small
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
        if(b[i]/a[i]<sm)
        {
            sm=b[i]/a[i];
        }
    }
    if(v<(sum*sm))
    {
        cout<<v;
    }
    else{cout<<(sum*sm);}
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

void solve()
{
    double n,V;cin>>n>>V;
    vector<double> a(n),b(n); for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    double x=400;
    for(int i=0;i<n;i++) x=min(x,b[i]/a[i]);
    double soup=0;
    for(int i=0;i<n;i++) soup+=a[i]*x;

    double ans=min(soup,V);
    printf("%.6f\n",ans);
}

int main()
{
    IO
    /*int t;
    cin>>t;
    while(t--)*/ solve();
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

void solve()
{
    int n,V;cin>>n>>V;
    vi a(n),b(n); for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    double lo=0,hi=V;
    double ans=0;int cnt=0;
    while(lo<=hi && cnt<100)
    {
        cnt++;
        int x=(lo+hi)/2;
        double sum=0;
        bool flg=true;
        for(int i=0;i<n;i++)
        {
            if(x*a[i]<=b[i]) sum+=x*a[i];
            else flg=false;
        }
        if(flg && sum<=double(V)){ans=max(sum,ans);lo=x;}
        else hi=x;
    }
    printf("%.6f\n",ans);
}

int main()
{
    IO
    /*int t;
    cin>>t;
    while(t--)*/ solve();
    return 0;
}


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

#define MAXN 21
#define ll long long int

vector<double> q(MAXN,0.0);
vector<double> a(MAXN,0.0);
int n;

bool check_true(double val){
    for(int i=1;i<n;i++){
        if(a[i]*val>q[i]){
            return false;
        }
    }
    return true;
}

int main(){
    double f;
    cin>>n;
    cin>>f;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>q[i];
    if(n==1){
        cout<<min(q[0],(double)f)<<"\n";
        return 0;
    }
    for(int i=1;i<n;i++){
        a[i]=a[i]/a[0];
    }
    double l=0;
    double r=q[0];
    double pmid=INT_MAX,mid;
    while(true){
        mid=(l+r)/2;
        //cout<<mid<<"\n";
        if(check_true(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
        if(abs(pmid-mid)<1e-9){
            //cout<<"Break:"<<pmid<<"\t"<<mid<<"\t"<<pmid-mid<<"\n";
            break;
        }
        pmid=mid;
    }
    double vol=pmid;
    for(int i=1;i<n;i++){
        vol+=a[i]*pmid;
    }
    cout<<min(vol,f)<<"\n";
    return 0;
}


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

#define MAXN 21
#define ll long long int

vector<double> q(MAXN,0.0);
vector<double> a(MAXN,0.0);
int n;

bool check_true(double val){
    for(int i=1;i<n;i++){
        if(a[i]*val>q[i]){
            return false;
        }
    }
    return true;
}

int main(){
    double f;
    cin>>n;
    cin>>f;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)cin>>q[i];
    if(n==1){
        cout<<min(q[0],(double)f)<<"\n";
        return 0;
    }
    for(int i=1;i<n;i++){
        a[i]=a[i]/a[0];
    }
    double l=0;
    double r=q[0];
    double pmid=INT_MAX,mid;
    while(true){
        mid=(l+r)/2;
        //cout<<mid<<"\n";
        if(check_true(mid)){
            l=mid;
        }
        else{
            r=mid;
        }
        if(abs(pmid-mid)<1e-5){
            //cout<<"Break:"<<pmid<<"\t"<<mid<<"\t"<<pmid-mid<<"\n";
            break;
        }
        pmid=mid;
    }
    double vol=pmid;
    for(int i=1;i<n;i++){
        vol+=a[i]*pmid;
    }
    cout<<min(vol,f)<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
//#include <boost/math/common_factor.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define Second S;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long long pinpow(long long a, long long b)
{
    if (b == 0)
        return 1;
    long long res = pinpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

long long binpow(long long a, long long b, long long m)
{
    a %= m;
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
/*
sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});

    for (const pair<int, int> &p: v)
    {
        cout << p.first <<" "<< p.second <<endl;
    }
*/
vector < double > r;
vector < double > vol;
int n;
double ans=-1;
void Bisection(int x,double y)
{
    double i,start=0,en=x,mid;

    while(start<=en)
    {
        mid=(start+en)/2;
        int p=0;
        for(i=0;i<n;i++)
        {
            double now;
            now=(r[i]/y)*mid;
            if(now>vol[i])
            {
                p=1;
                break;
            }
        }

        if(p==1)
        {
            en=mid-0.00001;
        }

        else
        {
            ans=max(ans,mid);
            start=mid+0.00001;
        }
    }

}
int main()
{
    int v,i,sum=0;
    cin >> n >> v;

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        sum+=x;
        r.push_back(x);
    }

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        vol.push_back(x);
    }

    Bisection(v,sum);
    if(ans==-1)
        cout << fixed << setprecision(5) << a << endl;
    else
        cout << fixed << setprecision(5) << a << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
//#include <boost/math/common_factor.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define Second S;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long long pinpow(long long a, long long b)
{
    if (b == 0)
        return 1;
    long long res = pinpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

long long binpow(long long a, long long b, long long m)
{
    a %= m;
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
/*
sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});

    for (const pair<int, int> &p: v)
    {
        cout << p.first <<" "<< p.second <<endl;
    }
*/
vector < double > r;
vector < double > vol;
int n;
double ans=-1;
void Bisection(int x,double y)
{
    double i,start=0,en=x,mid;

    while(start<=en)
    {
        mid=(start+en)/2;
        int p=0;
        for(i=0;i<n;i++)
        {
            double now;
            now=(r[i]/y)*mid;
            if(now>vol[i])
            {
                p=1;
                break;
            }
        }

        if(p==1)
        {
            en=mid-0.00001;
        }

        else
        {
            ans=max(ans,mid);
            start=mid+0.00001;
        }
    }

}
int main()
{
    int v,i,sum=0;
    cin >> n >> v;

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        sum+=x;
        r.push_back(x);
    }

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        vol.push_back(x);
    }

    Bisection(v,sum);
    if(ans==-1)
        cout << 0.0 << endl;
    else
        cout << fixed << setprecision(5) << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
//cout << "Case " << ca << ": " << ans << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define MX 100005
#define infinity 20000000
#define pb push_back
//#include <boost/math/common_factor.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define Second S;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
long long pinpow(long long a, long long b)
{
    if (b == 0)
        return 1;
    long long res = pinpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

long long binpow(long long a, long long b, long long m)
{
    a %= m;
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
/*
sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});

    for (const pair<int, int> &p: v)
    {
        cout << p.first <<" "<< p.second <<endl;
    }
*/
vector < double > r;
vector < double > vol;
int n;
double ans=-1;
void Bisection(int x,double y)
{
    double i,start=0,en=x,mid;

    while(start<=en)
    {
        mid=(start+en)/2;
        int p=0;
        for(i=0;i<n;i++)
        {
            double now;
            now=(r[i]/y)*mid;
            if(now>vol[i])
            {
                p=1;
                break;
            }
        }

        if(p==1)
        {
            en=mid-0.00001;
        }

        else
        {
            ans=max(ans,mid);
            start=mid+0.00001;
        }
    }

}
int main()
{
    int v,i,sum=0;
    cin >> n >> v;

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        sum+=x;
        r.push_back(x);
    }

    for(i=1; i<=n; i++)
    {
        double x;
        cin >> x;
        vol.push_back(x);
    }

    Bisection(v,sum);
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define NIL -(long long)(1e9)
#define ll long long
#define satir cout<<"\n"
#define ALL(v) (v).begin(), (v).end()
#define f first
#define s second
#define sps <<" "<<
#define sp <<" "
#define spl cout<<"\n";
#define mp make_pair
#define INF 0x3f3f3f3f
#define cntout cout<<" "<<rndcntbo; ++rndcntbo;
const ll N = 20005;
ll n,n1,n2,V,n3,k,t,d1,d2,m,ans=-1,rndcntbo=190;
double a[26];
double b[26];

inline void coz(){
cin>>n>>V;
for (int i = 0; i < n; ++i)
{
	cin>>a[i];
	// cout<<a[i];
}
double big=10000;
for (int i = 0; i < n; ++i)
{
	cin>>b[i];
	// cout<<b[i];spl;
	// ]/a[i]*1.0 > big)
	big=fmin(b[i]/a[i]*1.0,big*1.0);
}
	cout.precision(8);
// cout<<big;spl;
	double tot=0;
	double ans=0;
	double l=0,r=big,mid;
	for (int i = 0; i < n; ++i)
		{
			tot += 1.0*big*a[i];
		}
	// while(l<=r){

	// 	mid= l+((r-l)/2.0);
	// 	// cout<<mid;spl;
	// 	tot=0;

	// 	if (tot<=V)
	// 	{	ans= tot;
	// 		l= mid+ 0.00001;
	// 	}else{
	// 		r=mid - 0.00001;
	// 	}
	// }
cout<<fmin(tot,V);
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// memset(parent,-	1,sizeof(parent));
#ifndef ONLINE_JUDGE
	freopen("factory.in","r",stdin);  freopen("factory.out","w",stdout);
#endif
// cin>>t;
// while(t--)
	coz();

// cout<<ans<<" ";
	return 0;
}


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0;
           string s;
         while(getline(cin,s))
         {
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s<<endl;
       }
       else if(q==1 && p==0)
       {
           cout<<s<<endl;
       }
       else if(p==0 && q==0)
       {
           cout<<s<<endl;
       }
       if(q==1)
       p=1;
         }

     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0,k=0;
           string s;
         while(getline(cin,s))
         {
             if(k==1)
             {
                 cout<<endl;
                 k=0;
             }
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s;
          k=1;
       }
       else if(q==1 && p==0)
       {
           cout<<s<<endl;
       }
       else if(p==0 && q==0)
       {
           cout<<s<<endl;
       }
       if(q==1)
       p=1;
         }

     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0,k=0;
           string s;
         while(getline(cin,s))
         {
             if(k==1)
             {
                 cout<<endl;
                 k=0;
             }
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s;
          k=1;
       }
       else if(q==1 && p==0)
       {
           cout<<s<<endl;
       }
       else if(p==0 && q==0)
       {
           cout<<s<<endl;
       }
       if(q==1)
       p=1;
         }
         cout<<endl;
     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0,k=0;
           string s;
         while(getline(cin,s))
         {
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           if(k==1)
           {
               cout<<endl;
               k=0;
           }
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s;
          k=1;
       }
       else if(q==1 && p==0)
       {
           cout<<s;
           k=1;
       }
       else if(p==0 && q==0)
       {
           cout<<s<<endl;
       }
       if(q==1)
       p=1;
         }
         cout<<endl;
     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0;
           string s;
         while(getline(cin,s))
         {
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s<<endl;
       }
       else if(q==1 && p==0)
       {
           cout<<s<<endl;
       }
       else if(p==0 && q==0)
       {
           cout<<s<<endl;
       }
       if(q==1)
       p=1;
         }
         cout<<endl;

     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;

    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);

            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}

int main()
{
     IOS
     int w;
    // cin>>w;
    // while(w--)
     {
          int p=0,q=0,k=0;
           string s;
         while(getline(cin,s))
         {
       ll n=s.size();
       int q=0;
       for(int i=0;i<n;i++)
       {
         if(s[i]=='#')
         {
             q=1;
         }
         else if(s[i]!=' ')
         {
             break;
         }
       }
       if(p==1 && q==0)
       {
           if(k==1)
           {
               cout<<endl;
               k=0;
           }
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
       }
       else if(q==1 && p==1)
       {
          cout<<endl<<s;
          k=1;
       }
       else if(q==1 && p==0)
       {
           if(k)
           cout<<endl;
           cout<<s;
           k=1;
       }
       else if(p==0 && q==0)
       {
           for(int i=0;i<n;i++)
           {
               if(s[i]!=' ')
               {
                   cout<<s[i];
               }
           }
           k=1;
       }
       if(q==1)
       p=1;
         }
         cout<<endl;
     }
     return 0;
}
//ascii of a=97
//ascii of A=65
//ascii of 0=48


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int lol(string s){
char last = '0';
for(int i = 0 ; i < s.length() ; i++){
    last = s[i];
    if(s[i] != ' ') break;
}
return last == '#';
}

int main()
{
    IO;
    string s;
    vector<string> lines;
    while(getline(cin ,s)){
        lines.push_back(s);
    }
    vector<int> ok(lines.size(), 1);
    for(int i = 0 ; i < lines.size() ; i++){
        if(lol(lines[i])){
            ok[i] = 0;
        }
    }
    int l = 0;
    for(int i = 0 ; i < lines.size() ; i++){
        if(!ok[i]) cout<<lines[i]<<endl, l = 1;
        else{
            for(int j = 0 ; j < lines[i].length() ; j++) if(lines[i][j] != ' ') cout<<lines[i][j];
            l = 0;
            if(i + 1 < lines.size() && !ok[i+1]) cout<<endl, l = 1;
        }

    }
    if(!l) cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int lol(string s){
char last = '0';
for(int i = 0 ; i < s.length() ; i++){
    last = s[i];
    if(s[i] != ' ') break;
}
return last == '#';
}

void fix(int ind, vector<int> &v){
    v[ind] = 0;
}

int main()
{
    IO;
    char s[1048579];
    vector<string> lines;
    while(gets(s)){
        lines.push_back(s);
    }
    vector<int> ok(lines.size(), 1);
    for(int i = 0 ; i < lines.size() ; i++){
        if(lol(lines[i])){
            fix(i, ok);
        }
    }
    for(int i = 0 ; i < lines.size() ; i++){
        if(!ok[i] && i) cout<<endl<<lines[i]<<endl;
        else if(!ok[i]) cout<<lines[i]<<endl;
        else{
            for(int j = 0 ; j < lines[i].length() ; j++) if(lines[i][j] != ' ') cout<<lines[i][j];
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int lol(string s){
char last = '0';
for(int i = 0 ; i < s.length() ; i++){
    last = s[i];
    if(s[i] != ' ') break;
}
return last == '#';
}

void fix(int ind, vector<int> &v){
    v[ind] = 0;
}

int main()
{
    IO;
    char s[1048579];
    vector<string> lines;
    while(gets(s)){
        lines.push_back(s);
    }
    vector<int> ok(lines.size(), 1);
    for(int i = 0 ; i < lines.size() ; i++){
        if(lol(lines[i])){
            fix(i, ok);
        }
    }
    int l = 0;
    for(int i = 0 ; i < lines.size() ; i++){
        if(!ok[i] && i) cout<<endl<<lines[i]<<endl, l = 1;
        else if(!ok[i]) cout<<lines[i]<<endl, l = 1;
        else{
            for(int j = 0 ; j < lines[i].length() ; j++) if(lines[i][j] != ' ') cout<<lines[i][j];
            l = 0;
        }
    }
    if(!l) cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int lol(string s){
char last = '0';
for(int i = 0 ; i < s.length() ; i++){
    last = s[i];
    if(s[i] != ' ') break;
}
return last == '#';
}

void fix(int ind, vector<int> &v){
    v[ind] = 0;
}

int main()
{
    IO;
    string s;
    vector<string> lines;
    while(getline(cin , s)){
        lines.push_back(s);
    }
    vector<int> ok(lines.size(), 1);
    for(int i = 0 ; i < lines.size() ; i++){
        if(lol(lines[i])){
            fix(i, ok);
        }
    }
    for(int i = 0 ; i < lines.size() ; i++){
        if(!ok[i] && i) cout<<endl<<lines[i]<<endl;
        else if(!ok[i]) cout<<lines[i]<<endl;
        else{
            for(int j = 0 ; j < lines[i].length() ; j++) if(lines[i][j] != ' ') cout<<lines[i][j];
        }
    }
    return 0;
}


#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;

int lol(string s){
char last = '0';
for(int i = 0 ; i < s.length() ; i++){
    last = s[i];
    if(s[i] != ' ') break;
}
return last == '#';
}

void fix(int ind, vector<int> &v){
    v[ind] = 0;
}

int main()
{
    IO;
    string s;
    vector<string> lines;
    while(getline(cin, s)){
        lines.push_back(s);
    }
    vector<int> ok(lines.size(), 1);
    for(int i = 0 ; i < lines.size() ; i++){
        if(lol(lines[i])){
            fix(i, ok);
        }
    }
    for(int i = 0 ; i < lines.size() ; i++){
        if(!ok[i] && i) cout<<endl<<lines[i]<<endl;
        else if(!ok[i]) cout<<lines[i]<<endl;
        else{
            for(int j = 0 ; j < lines[i].length() ; j++) if(lines[i][j] != ' ') cout<<lines[i][j];
        }
    }
    return 0;
}


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

#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); cout.precision(15)
#define fi first
#define len(x) int(x.length())
#define mp make_pair
#define pb emplace_back
#define pf emplace_front
#define re return
#define se second
#define sqr(x) ((x) * (x))
#define sz(x) int(x.size())
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

void solve()
{
	string s, ans = "";
	vs in;
	while (getline(cin, s)) {
		in.pb(s + '\n');
	}
	vb power(sz(in), 0);
	bool start;
	for (int i = 0; i < sz(in); i++) {
		start = 1;
		for (int j = 0; j < len(in[i]); j++) {
			if (in[i][j] == '#') {
				if (start) {
					power[i] = 1;
					break;
				}
			}
			else if (in[i][j] != ' ') start = 0;
		}
	}
	for (int i = 0; i < sz(in); i++) {
		for (int j = 0; j < len(in[i]) - 1; j++) {
			if (power[i] || in[i][j] != ' ') {
				ans += in[i][j];
			}
		}
		if (!(i != sz(in) - 1 && !power[i] && !power[i + 1])) ans += '\n';
	}
	cout << ans << endl;
}

int main() {
	fastIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	re 0;
}


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

#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); cout.precision(15)
#define fi first
#define len(x) int(x.length())
#define mp make_pair
#define pb emplace_back
#define pf emplace_front
#define re return
#define se second
#define sqr(x) ((x) * (x))
#define sz(x) int(x.size())
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

void solve()
{
	string s, ans = "";
	vs in;
	while (getline(cin, s)) {
		in.pb(s);
	}
	vb power(sz(in), 0);
	bool start;
	for (int i = 0; i < sz(in); i++) {
		start = 1;
		for (int j = 0; j < len(in[i]); j++) {
			if (in[i][j] == '#') {
				if (start) {
					power[i] = 1;
					break;
				}
			}
			else if (in[i][j] != ' ') start = 0;
		}
	}
	for (int i = 0; i < sz(in); i++) {
		for (int j = 0; j < len(in[i]); j++) {
			if (power[i] || in[i][j] != ' ') {
				ans += in[i][j];
			}
		}
		if (i != sz(in) - 1 && !power[i] && !power[i + 1]) ans += '\n';
	}
	cout << ans << endl;
}

int main() {
	fastIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	re 0;
}


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

#define all(x) x.begin(), x.end()
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); cout.precision(15)
#define fi first
#define len(x) int(x.length())
#define mp make_pair
#define pb emplace_back
#define pf emplace_front
#define re return
#define se second
#define sqr(x) ((x) * (x))
#define sz(x) int(x.size())
typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

void solve()
{
	string s, ans = "";
	vs in;
	while (getline(cin, s)) {
		in.pb(s);
	}
	vb power(sz(in), 0);
	bool start;
	for (int i = 0; i < sz(in); i++) {
		start = 1;
		for (int j = 0; j < len(in[i]); j++) {
			if (in[i][j] == '#') {
				if (start) {
					power[i] = 1;
					break;
				}
			}
			else if (in[i][j] != ' ') start = 0;
		}
	}
	for (int i = 0; i < sz(in); i++) {
		for (int j = 0; j < len(in[i]); j++) {
			if (power[i] || in[i][j] != ' ') {
				ans += in[i][j];
			}
		}
		if (i != sz(in) - 1 && (power[i] || power[i + 1])) ans += '\n';
	}
	cout << ans << endl;
}

int main() {
	fastIO;
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	re 0;
}


#define NDEBUG

#include <bits/stdc++.h>

using namespace std;
using pii = pair<int, int>;

#ifdef NDEBUG
#  define debug(...)
#else
#  include "debug.hh"
#endif

string s;
bool dirty;

bool amp() {
  for (char c: s) {
    if (c != ' ') return c == '#';
  }
  return false;
}

void flush() {
  if (dirty) cout << '\n', dirty = false;
}

int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed;
  while (getline(cin, s)) {
    if (amp()) {
      flush();
      cout << s << '\n';
    } else {
      for (char c: s) {
        if (c != ' ') cout << c;
      }
      dirty = true;
    }
  }
  flush();
  return 0;
}


//AUTHOR : TIRTH JARSANIA
//COLLEGE : DAIICT

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

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define bp __builtin_popcountll
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<ll,ll>
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define maxQueue priority_queue<pii>
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
	FAST;

	string s;
	bool f = false, ff = true;

	while (getline(cin, s)){
		ff = true;

		for (int i=0; i<s.size(); i++){

			if (s[i] != ' '){
				ff = false;
				if (s[i] != '#'){
					for (int i=0; i<s.size(); i++){
						if (s[i] != ' ') cout << s[i];
					}
					f = true;

				} else {
					if (f) cout << endl;
					cout << s << endl;
					f = false;
				}
				break;
			}
		}
		if (f) first = true;
	}
	if (f) cout << endl;
	return 0;
}


//AUTHOR : TIRTH JARSANIA
//COLLEGE : DAIICT

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

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define bp __builtin_popcountll
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<ll,ll>
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> >
#define maxQueue priority_queue<pii>
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
	FAST;

	string s;
	bool f = false, ff = true;

	while (getline(cin, s)){
		ff = true;

		for (int i=0; i<s.size(); i++){

			if (s[i] != ' '){
				ff = false;
				if (s[i] != '#'){
					for (int i=0; i<s.size(); i++){
						if (s[i] != ' ') cout << s[i];
					}
					f = true;

				} else {
					if (f) cout << endl;
					cout << s << endl;
					f = false;
				}
				break;
			}
		}
		if (ff)f = true;
	}
	if (f) cout << endl;
	return 0;
}


// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
const double pi=acos(-1); // value of pi

// map<ll, list<ll>> m;

bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

map<ll, list<ll>> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    // cin >> t;
    while(t--) {
        string a, res="";
        vector<string> s;
        while((getline(cin, a))) {
            s.push_back(a);
        }
        ll ans[s.size()]={0};
        for(ll i=0; i<s.size(); i++) {
            for(ll j=0; j<s[i].length(); j++) {
                if(s[i][j]!=' ' && s[i][j]!='#') {
                    ans[i]=0;
                    break;
                }
                else if(s[i][j]=='#') {
                    ans[i]=1;
                    break;
                }
            }
        }
        for(ll i=1; i<s.size(); i++) {
            if(ans[i-1]==1) {
                res+=s[i-1];
                res+='\n';
            }
            else {
                for(ll j=0; j<s[i-1].length(); j++) {
                    if(s[i-1][j]!=' ') {
                        res+=s[i-1][j];
                    }
                }
                if(ans[i]==1 && ans[i-1]==0) {
                    res+='\n';
                }
            }
        }
        res+=s[s.size()-1];
        cout << res << endl;
    }
}


// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
const double pi=acos(-1); // value of pi

// map<ll, list<ll>> m;

bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

map<ll, list<ll>> m;

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    // cin >> t;
    while(t--) {
        string a, res="";
        vector<string> s;
        while((getline(cin, a))) {
            s.push_back(a);
        }
        ll ans[s.size()]={0};
        for(ll i=0; i<s.size(); i++) {
            for(ll j=0; j<s[i].length(); j++) {
                if(s[i][j]!=' ' && s[i][j]!='#') {
                    ans[i]=0;
                    break;
                }
                else if(s[i][j]=='#') {
                    ans[i]=1;
                    break;
                }
            }
            string temp="";
            if(!ans[i]) {
                for(ll j=0; j<s[i].length(); j++) {
                    if(s[i][j]!=' ') {
                        temp+=s[i][j];
                    }
                }
                s[i]=temp;
            }
        }
        cout << s[0];
        for(ll i=1; i<s.size(); i++) {
            if(!ans[i-1] && !ans[i]) {
                cout << s[i];
            }
            else {
                cout << '\n' << s[i];
            }
            if(ans[i-1]==1) {
                res+=s[i-1];
                res+='\n';
            }
            else {
                for(ll j=0; j<s[i-1].length(); j++) {
                    if(s[i-1][j]!=' ') {
                        res+=s[i-1][j];
                    }
                }
                if(ans[i]==1 && ans[i-1]==0) {
                    res+='\n';
                }
            }
        }
        res+=s[s.size()-1];
        cout << '\n';
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1048577;
string a;
int main()
{
    int lapos=0;
    while(getline(cin,a))
    {
        int tt=a.length();
        int fi=0;
        for(int i=0;i<tt;i++)
        {
            if(a[i]==' ')
            {
                continue;
            }
            else if(a[i]=='#')
            {
                fi=1;
                break;
            }
            else
            {
                fi=0;
                break;
            }
        }
//        printf("<<<%s>>>",a);
        if(fi==1)
        {
            if(lapos==1)
            {
                printf("\n");
            }
            else if(lapos==2)
            {
                printf("\n");
            }
            lapos=0;
            cout<<a<<endl;
        }
        else
        {
            for(int i=0;i<tt;i++)
            {
                if(a[i]==' ')
                {
                    continue;
                }
                else
                {
                    printf("%c",a[i]);
                    lapos=2;
                }
            }
            if(lapos==0)
            {
                lapos=1;
            }
        }
//        getchar();
    }
    if(lapos!=0)
    {
        printf("\n");
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1048577;
char a[maxn];
int main()
{
    int lapos=0;
    while(gets(a)!=0)
    {
        int tt=strlen(a);
        int fi=0;
        for(int i=0;i<tt;i++)
        {
            if(a[i]==' ')
            {
                continue;
            }
            else if(a[i]=='#')
            {
                fi=1;
                break;
            }
            else
            {
                fi=0;
                break;
            }
        }
//        printf("<<<%s>>>",a);
        if(fi==1)
        {
            if(lapos==1)
            {
                printf("\n");
            }
            else if(lapos==2)
            {
                printf(" \n");
            }
            lapos=0;
            printf("%s\n",a);
        }
        else
        {
            for(int i=0;i<tt;i++)
            {
                if(a[i]==' ')
                {
                    continue;
                }
                else
                {
                    printf("%c",a[i]);
                    lapos=2;
                }
            }
            if(lapos==0)
            {
                lapos=1;
            }
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1048577;
string a;
int main()
{
    int lapos=0;
    while(getline(cin,a))
    {
        int tt=a.length();
        int fi=0;
        for(int i=0;i<tt;i++)
        {
            if(a[i]==' ')
            {
                continue;
            }
            else if(a[i]=='#')
            {
                fi=1;
                break;
            }
            else
            {
                fi=0;
                break;
            }
        }
//        printf("<<<%s>>>",a);
        if(fi==1)
        {
            if(lapos==1)
            {
                printf("\n");
            }
            else if(lapos==2)
            {
                printf("\n");
            }
            lapos=0;
            cout<<a<<endl;
        }
        else
        {
            for(int i=0;i<tt;i++)
            {
                if(a[i]==' ')
                {
                    continue;
                }
                else
                {
                    printf("%c",a[i]);
                    lapos=2;
                }
            }
            if(lapos==0)
            {
                lapos=1;
            }
        }
//        getchar();
    }
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1048577;
string a;
int main()
{
    int lapos=0;
    while(getline(cin,a))
    {
        int tt=a.length();
        int fi=0;
        for(int i=0;i<tt;i++)
        {
            if(a[i]==' ')
            {
                continue;
            }
            else if(a[i]=='#')
            {
                fi=1;
                break;
            }
            else
            {
                fi=0;
                break;
            }
        }
//        printf("<<<%s>>>",a);
        if(fi==1)
        {
            if(lapos==1)
            {
                printf("\n");
            }
            else if(lapos==2)
            {
                printf(" \n");
            }
            lapos=0;
            cout<<a<<endl;
        }
        else
        {
            for(int i=0;i<tt;i++)
            {
                if(a[i]==' ')
                {
                    continue;
                }
                else
                {
                    printf("%c",a[i]);
                    lapos=2;
                }
            }
            if(lapos==0)
            {
                lapos=1;
            }
        }
//        getchar();
    }
}


#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

string x = "";
bool flag = 0;

bool ok(string s)
{
    for(int i = 0; i < s.size() ; i ++)
    {
        if(s[i] == ' ')
            continue ;
        if(s[i] == '#')
            return true ;
        return false ;
    }
    return false ;
}

void join(string s)
{
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] == ' ')
            continue ;
        else
            x += s[i];
    }
}

void solve()
{
    string s;
    while(getline(cin, s))
    {
        if(ok(s))
        {
            if(flag)
            {
                flag = 0;
                cout<<x<<endl;
            }
            cout<<s<<endl;
            x = "";
        }
        else
        {
            flag = 1;
            join(s);
        }
    }
    if(flag)
        cout<<x<<endl;
    return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
    t = 1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;
const int M = 1e6 + 500;

string x = "";
bool flag = 0;

bool ok(string s)
{
    for(int i = 0; i < s.size() ; i ++)
    {
        if(s[i] == ' ')
            continue ;
        if(s[i] == '#')
            return true ;
        return false ;
    }
    return false ;
}

void join(string s)
{
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] == ' ')
            continue ;
        else
            x += s[i];
    }
}

void solve()
{
    string s;
    while(getline(cin, s))
    {
        if(ok(s))
        {
            if(flag)
            {
                flag = 0;
                cout<<x<<endl;
            }
            cout<<s<<endl;
            x = "";
        }
        else
        {
            flag = 1;
            join(s);
        }
    }
    if(x != "")
        cout<<x<<endl;
    return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
    t = 1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


// practice with Dukkha
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1 << 20;

char qu[N + 1], cc[N + 1];

bool printable(char c) {
	return 33 <= c && c <= 126;
}

int main() {
	bool line = false;
	int cnt = 0;
	while (fgets(cc, N + 1, stdin) != NULL) {
		int n = strlen(cc) - 1;
		int i = 0;
		while (i < n && !printable(cc[i]))
			i++;
		if (i < n && cc[i] == '#') {
			if (line) {
				line = false;
				qu[cnt] = 0;
				cout << qu << '\n';
				cnt = 0;
			}
			cout << cc;
		} else {
			line = true;
			for (i = 0; i < n; i++)
				if (printable(cc[i]))
					qu[cnt++] = cc[i];
		}
	}
	if (line) {
		line = false;
		qu[cnt] = 0;
		cout << qu << '\n';
		cnt = 0;
	}
	return 0;
}


// practice with Dukkha
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

const int N = 1 << 20;

char qu[N + 1], cc[N + 1];

int main() {
	bool line = false;
	int cnt = 0;
	while (fgets(cc, N + 1, stdin) != NULL) {
		int n = strlen(cc) - 1;
		int i = 0;
		while (i < n && cc[i] == ' ')
			i++;
		if (i < n && cc[i] == '#') {
			if (line) {
				line = false;
				qu[cnt] = 0;
				cout << qu << '\n';
				cnt = 0;
			}
			cout << cc;
		} else {
			line = true;
			for (i = 0; i < n; i++)
				if (cc[i] != ' ')
					qu[cnt++] = cc[i];
		}
	}
	if (line) {
		line = false;
		qu[cnt] = 0;
		cout << qu << '\n';
		cnt = 0;
	}
	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
bool lst = 0;
vector<int> gg;
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		if(good(curr)){
			cout<<curr<<"\n";
			lst = 1;
		}else{
			lst = 0;
			for(char c : curr){
				if(c != ' ') cout<<c;
			}
			if(i + 1 < n && gg[i+1]) cout<<"\n";
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	while(getline(cin,s)){
		arr.pb(s);
		gg.pb(good(s));
	}

	get(arr);
	if(!lst) cout<<"\n";
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		//cout<<curr<<" "<<good(curr)<<"\n";
		if(good(curr)) ret+= (ret.size() ? "\n" : "") + curr+"\n";
		else{
			for(char c : curr){
				if(c != ' ' && c != '\n') ret += c;
			}
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	getline(cin, s);

	while(1){
		arr.pb(s);
		getline(cin, s);
		//cout<<s<<"\n";
	    if(s.size() == 0) break;

	}
	cout<<get(arr)<<"\n";
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		//cout<<curr<<" "<<good(curr)<<"\n";
		if(good(curr)) ret+= (ret.size() ? "\n" : "") + curr+"\n";
		else{
			for(char c : curr){
				if(c != ' ' && c != '\n') ret += c;
			}
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	getline(cin, s);

	while(1){
		arr.pb(s);
		getline(cin, s);
		//cout<<s<<"\n";
	    if(s.size() == 0) break;

	}
	cout<<get(arr);
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<long long,int>, null_type, less<pair<long long,int>>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define f first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pi pair<int, int>
#define all(num) num.begin(), num.end()
#define lp(i, nodess) for (int i = 0; i < nodess; i++)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define X real()
#define Y imag()
#define angle(u) (atan2(u.Y, u.X))
#define vec(u, v) ((v) - (u))
//#define length(u) (hypot(u.Y , u.X))
#define normalize(u) (u) / length(u)
#define dotP(u, v) ((conj(u) * v).X)
#define crossP(u, v) ((conj(u) * v).Y)
#define same(p1, p2) (dotP(vec(p1, p2), vec(p1, p2)) < EPS)
#define lengthSqr(u) dotP(u, u)
#define rotate0(p, ang) ((p)*exp(point(0, ang)))
#define rotateA(p, ang, about) (rotate0(vec(about, p), ang) + about)
#define reflect0(vis, m) conj(vis / m) * m
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
const double PI = acos(-1.0);
const double EPS = (1e-10);
const long long int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
typedef long long int ll;
typedef unsigned long long ull;
typedef complex<double> point;
long long fastpow(ll nodess, ll num, ll m) {
  if (!num)
    return 1;
  if (num % 2)
    return nodess * fastpow(nodess, num - 1, m)%m;
  ll p = fastpow(nodess, num / 2, m);
  p %= m;
  p *= p;
  p %= m;
  return p;
}

ll my_mod(ll num, ll mod) {
  ll reto = num % mod;
  while (reto < 0)
    reto += mod;
  return reto;
}

ll gcd(ll u, ll v) { return !u ? v : gcd(v % u, u); }
long long dist(pair<ll, ll> u, pair<ll, ll> v) {
  return
      abs(u.f - v.f)  + abs(u.se - v.se);
}
long long getDist(pair<ll, ll> &u, pair<ll, ll> &v) {
  return
     (u.f - v.f)*(u.f - v.f)  + (u.se - v.se)*(u.se-v.se);
}

/*vector<int> ap;
int np[MX+5];
void s(){
    mem(np , 1);
    np[1] = np[0] = 0;
    for(ll i = 2 ; i*i<= MX ;i++){
        if(np[i]){
            for(ll j= i*i ; j <=MX; j+=i) np[j] = 0;
        }
    }
    int idx = 1;
    for(ll i = 2 ; i<= MX ; i++){
		if(np[i]){
			np[i] = idx;
			idx++;
			ap.pb(i);
		}
	}
	//cout<<idx;
}*/
const int MX = 10009;
bool good(string &s){
	bool notspace = 0;
	for(int i =0 ;i < (int)s.size(); i++){
		if(s[i] == '#' && !notspace) return 1;
		notspace |= s[i] != ' ';
	}
	return 0;
}
bool lst = 0;
string get(vector<string>& input){
	string ret = "";
	int n = input.size();
	for(int i = 0; i< n ;i++){
		string &curr = input[i];
		if(good(curr)){

			 ret+= (ret.size() ? "\n" : "") + curr+"\n";
			lst = 1;
		}else{
			lst = 0;
			for(char c : curr){
				if(c != ' ') ret += c;
			}
		}
	}
	return ret;
}
int main()
{
   // IO;
	vector<string> arr;
	string s;
	while(getline(cin,s)){
		arr.pb(s);
	}
	string ans = get(arr);
	if(!lst) ans += "\n";
	cout<<get(arr);
	//for(string x : arr) cout<<x<<"\n";

	return 0;
}