#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  int A, B;
  cin >> A >> B;
  cout << A + B << endl;

  return 0;
}

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

int main(){
  int g;
  cin >>g;
  int a,b;
  cin >>a >>b;
  if(g==1){cout << "Hello World" << endl;}else{cout << a+b << endl;}
}


//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+17;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数

//ライブラリ挿入

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    vector<vector<ll>> dp(N+1,vector<ll>(2,0));
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=0;
    dp[1][1]=A[0];

    REP2(i,1,N){
        if(i%2==1){
            dp[i+1][0]=max(dp[i][1],dp[i-1][0]+A[i]);
        }else{
            dp[i+1][0]=max(dp[i][0],dp[i-1][0]+A[i]);
            dp[i+1][1]=dp[i-1][1]+A[i];
        }
    }
    cout<<dp[N][0]<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=3e5+2;
ll M=1e9+7;
ll a[N];
int main()
{
    ft
    ll i,j,n,s=0,l,r,m;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=0,m=1;i<61;i++,m*=2)
    {
        l=r=0;
        for(j=0;j<n;j++)
        {
            (a[j]%2)? l++: r++;
            a[j]/=2;
        }
        s+=(((l*r)%M)*(m%M))%M;
        s%=M;
    }
    cout<<s<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t ans=1;
  int m,j,k,y,mod=1e9+7;
  bool f;
  cin>>m;
  vector<int> p={2};
  for(j=3;j<=m;j+=2){
    f=true;
    for(k=0;k<(int)p.size();k++){
      if(j%p.at(k)==0){
        f=false;
        break;
      }
    }
    if(f==true) p.push_back(j);
  }
  int l=p.size();
  vector<int> x(l);
  for(j=2;j<=m;j++){
    y=j;
    for(k=0;k<l;k++){
      while(y%p.at(k)==0){
        x.at(k)++;
        y/=p.at(k);
      }
      if(y==1) break;
    }
  }
  for(auto z:x) ans=ans*(z+1)%mod;
  cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 int H, W;
 int seen[10000][10000];
  char S[10000][10000];
vector<pair<ll, ll>> prime_factorize(ll n) { //素因数分解と各素数の個数
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        int num = 0;

        while (n % i == 0)
        {
            ++num;
            n /= i;
        }
        res.push_back(make_pair(i, num));

    }
     if (n != 1)
        {
            res.push_back(make_pair(n, 1));
        }
        return res;

}
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void dfs(int st, int fi) {
  //  cout << st << " " << fi <<  endl;
    if (st < 0 || fi < 0 || st >= H || fi >= W)
    {
        return ;
    }
    if (S[st][fi] == '#')
    {
        return ;
    }

    if (seen[st][fi] == 1)
    {
        return ;
    }

    if (S[st][fi] == '.')
    {
        seen[st][fi] = 1;
    }

    dfs(st + 1, fi);
    dfs(st, fi + 1);
    dfs(st, fi - 1);
    dfs(st - 1, fi);

}
int main() {
    int N;
    cin >> N;
    vector<int> p(N + 1);
    p[1] = 0;
    for(int i = 2; i <= N; i++) {
        int n = i;
        vector<pair<int, int>> b;
       for(int j = 2; j * j <= n; j++) {
           if(n % j != 0) continue;
           int ex = 0;

           while(n % j == 0) {
               ex++;
               n /= j;
           }

           b.push_back({j, ex});
       }
       if(n != 1) b.push_back({n, 1});

       for(auto v : b) {
           p[v.first] += v.second;
       }
    }

    /*for(int i = 1; i <= N; i++)
        cout << p[i] << endl;*/

    ll ans = 1;

    for(int i = 2; i <= N; i++) {
        ans *= (p[i] + 1);
        ans %= 1000000007;
    }

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


#include<iostream>

using namespace std;
int dp[31] ={1,2,4},step;
int main(){
  for(int i=3;i<31;i++){
    dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
  }
  while(cin>>step,step){
    cout<<(dp[step-1])/3650+1<<endl;
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void computeLPSArray(string pattern, int m, int lps[]){
    int len=0;
    lps[0]=0;   //lps[0] is always 0
    int i=1;
    while(i<m){
        if(pattern[i]==pattern[len]){
            len++;
            lps[i]=len;
            i++;
        }else{
            if(len!=0)
                len=lps[len-1];
            else{
                lps[i]=0;
                i++;
            }
        }
    }
}
void kmpSearch(string str,string pattern){
    int m=pattern.length();
    int n=str.length();
    int lps[m];  //longest prefix suffix array
    computeLPSArray(pattern,m,lps);
    int i=0; //text
    int j=0; //pattern
    bool found=0;
    while(i<n){
        if(pattern[j]==str[i]){
            i++;
            j++;
        }
        if(j==m){
            j=lps[j-1];
            found=1;
            break;
        }else if(i<n && pattern[j]!=str[i]){
            if(j!=0) j=lps[j-1];
            else i=i+1;
        }
    }
    if(!found)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str,pattern;
    while(cin>>str){
        pattern="AC";
        kmpSearch(str,pattern);
    }
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string s, ans = "No";
    cin >> s;
    rep(i, s.size() - 1)if(s[i] == 'A' && s[i + 1] == 'C')ans = "Yes";

    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    struct dice{int u,e,w,n,s,d;
    void rotate(char c){
        int temp=u;
        if(c=='E'){u=w;w=d;d=e;e=temp;}
        else if(c=='W'){u=e;e=d;d=w;w=temp;}
        else if(c=='N'){u=s;s=d;d=n;n=temp;}
        else if(c=='S'){u=n;n=d;d=s;s=temp;}
    }
    bool hikaku(dice q){
        int counter=0;
        if(u==q.u)counter++;
        if(s==q.s)counter++;
        if(e==q.e)counter++;
        if(w==q.w)counter++;
        if(n==q.n)counter++;
        if(d==q.d)counter++;
        if(counter==6)return true;else return false;
    }
    };
    int n;
    in(n);
    vector<dice> vec(n);
    rep(i,n){
        in(vec[i].u,vec[i].s,vec[i].e,vec[i].w,vec[i].n,vec[i].d);
    }
    string s="NNNNENNNN";
    for(int j=0;j<n-1;j++){
        for(int k=j+1;k<n;k++){
            dice a=vec[j];
            dice b=vec[k];
        rep(i,9){
            if(a.s==b.s)break;
            b.rotate(s[i]);
        }
        int counter=0;
        while(!a.hikaku(b)){
            b.rotate('E');
            counter++;
            if(counter>=5){
                goto skip;
            }
        }
        out("No");
        return 0;
        skip: ;
        }
    }
    out("Yes");
}

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

ll count ( ll n)
{
    ll ans =0;
    while( n%2==0)
    {
        n= n/2;
        ans++;
    }
    return ans;
}

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll ans = INT_MAX;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        ans = min(ans , count(a[i]));
    }
    cout<<ans;
}


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

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

    for(int p=0;p<testcase;p++){
    ll n=0,x=0;
    cin>>n>>x;
    ll array[n]={0};
	ll totalsum=0;
    for(int i=0;i<n;i++){
    cin>>array[i];
    totalsum+=array[i];
    }
    if(totalsum<x){
        cout<<n-1;
    }
else if(totalsum==x)
cout<<n;
    else
    {
        sort(array,array+n);
        ll counter=0;
        ll sum=x;
        ll i=0;
        while(sum>=0){
       // cout<<array[i];
        sum-=array[i];
    	if(sum<0)
    	break;
	    i++;
        counter++;
        }
        cout<<counter;
    }

    }

    return 0;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  int N;
  int64_t x;
  cin >> N >> x;

  vector<int64_t> a(N);
  rep(i, N) { cin >> a[i]; }

  sort(a.begin(), a.end());
  rep(i, N - 1) { a[i + 1] += a[i]; }

  auto p = lower_bound(a.begin(), a.end(), x);
  if (p == a.end()) {
    cout << N - 1 << endl;
  } else if (*p > x) {
    cout << p - a.begin() << endl;
  } else {
    cout << p - a.begin() + 1 << endl;
  }

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a;
    int dp[n];
    int ans=0;
    for(int i=0;i<n;i++)dp[i]=1e9;
    for(int i=0;i<n;i++){
        cin >> a;
        a *= (-1);
        *upper_bound(dp,dp+n,a)=a;
    }
    cout << lower_bound(dp,dp+n,1e9)-dp;
}

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

int main(){
  int  h1, m1, h2, m2 ,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int h3 = h2 -1;
  int m3 = m2 + 60;
  int a = (h3-h1)*60+(m3-m1);
  cout << max(a-k, 0) << endl;
  return 0;
}


#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>

using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    rep(i, s.size()-8)cout << s[i];
}

#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int a, b ,c, d;
    cin >> a >> b >> c >> d;

    print(min(a, b) + min(c, d));

}


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

int main()
{
  string s;
  cin >> s;

  bool flag1 = false, flag2 = false, flag3 = false;

  if (s[0] == 'A') flag1 = true;

  int counter_1 = 0;
  for (int i = 2; i < s.size()-1; ++i) {
    if (s[i] == 'C') ++counter_1;
    else continue;
  }

  if (counter_1 == 1) flag2 = true;

  int counter_2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (isupper(s[i])) ++counter_2;
    else continue;
  }

  if (counter_2 == 2) flag3 = true;

  if (flag1 && flag2 && flag3) cout << "AC" << "\n";
  else cout << "WA" << "\n";

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, k, n) for (int i = k+1; i < int(n); i++)
typedef long long LL;
typedef pair<int, int> PII;

int digit(long n){
	int dig = 1;
  	while(n / 10 > 0){
		n /= 10;
      	dig++;
    }
  	return dig;
}

long search_mul(long small, long big, long n){
    long a,b;
    int i;
    for(i = small + 1; i < big; i++){
        if(n % i == 0){
            a = i;
            b = n/a;
            if(n % (a * small) == 0 && a*small < n/(a*small)){
                a = a * small;
                b = n/a;
                //cout << a << " * " << b << endl;
                return search_mul(a,b,n);
            }
            //cout << a << " * " << b << endl;
            //return min(digit(b), search_mul(a,b,n));
            return search_mul(a,b,n);
        }
    }
    //cout << small << " * " << big << " ,ans :";
    return big;
}
void f(long n) {
  int ans;
  long temp = sqrt(n)+1;
  long ret;

  ret = search_mul(1,temp,n);

  if(ret == temp)
    ans = digit(n);
  else
    ans = digit(ret);
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n;
  cin >> n;
  f(n);
  return 0;
}


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

int main()
{
    cin >> K;
    cout << 50 << endl;
    for (int i=0; i<=50; i++)
    {
        if (50-i != K%50) cout << K/50 + i << " ";
    }
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n;
  cin >> n;
  vector<int> a;
  a.push_back(0);
  rep (i, n) {
    int x; cin >> x;
    a.push_back(x);
  }
  a.push_back(0);

  ll sum = 0;
  for (int i = 1; i < n + 2; i++) {
    sum += abs(a[i] - a[i - 1]);
    //printf("abs(a[%d] - a[%d]) = %d\n", i, i - 1, abs(a[i] - a[i - 1]));
  }

  for (int i = 1;  i < n + 1; i++) {
    ll tmp = sum;
    tmp -= abs(a[i] - a[i - 1]);
    tmp -= abs(a[i + 1] - a[i]);
    tmp += abs(a[i - 1] - a[i + 1]);
    cout << tmp << endl;
  }

  //printVec(a);

  //printf("sum = %d\n", sum);

  return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    ll ans = 0;
    ll fl = 0;
    if (z[0] > 0)fl = -1;
    for (int i = 1; i < n; i++) {
        if (z[i - 1] + 1 < z[i])fl = -1;
    }
    if (fl == -1)cout << -1 << endl;
    else {
        ans += z[n - 1];
        for (int i = n-2; i > 0; i--) {
            if (z[i + 1] <= z[i])ans += z[i];
        }
        cout << ans << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<ll>vec(3);
  ll a=0;
  for(ll i=0;i<3;i++){
    cin>>vec.at(i);
    a+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<a-vec.at(2)<<endl;
  return 0;
}

#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int a,b,c,e=0,z,d,f,g;
    cin>>a>>b>>c;
    z=min((a+b),(b+c));
    z=min(z,(c+a));
    cout<<z;
    return 0;
}


#include <iostream>
#include <time.h>
#include <algorithm>
#include <stdio.h>
#include<string.h>

typedef long long LL;

using namespace std;

const int times = 20;
LL fac[1001];
int cnt;

LL mul(LL a, LL b, LL mod)
{
	LL ans = 0;
	while (b)
	{
		if (b & 1)
		{
			ans = (ans + a) % mod;
		}
		a = (a << 1) % mod;
		b >>= 1;
	}
	return ans;
}

LL pow(LL a, LL b, LL mod)
{
	LL ans = 1;
	while (b)
	{
		if (b & 1)
		{
			ans = mul(ans, a, mod);
		}
		b >>= 1;
		a = mul(a, a, mod);
	}
	return ans;
}

bool witness(LL a, LL n)
{
	LL temp = n - 1;
	int j = 0;
	while (temp % 2 == 0)
	{ // 其实就是得到 m
		j++;
		temp /= 2;
	}
	LL x = pow(a, temp, n);
	if (x == 1 || x == n - 1)
	{ // 判断a^m
		return true;
	}
	while (j--)
	{
		x = mul(x, x, n); // 进一步判断 a^(2m)  a^(4m) ...
		if (x == n - 1)
			return true;
	}
	return false;
}

bool miller_rabin(LL n)
{
	if (n == 2)
	{ //  如果是2肯定是素数
		return true;
	}
	if (n < 2 || n % 2 == 0)
	{ //如果小于2或者是大于2的偶数肯定不是素数
		return false;
	}
	for (int i = 0; i < times; i++)
	{ //随机化检验
		LL a = rand() % (n - 1) + 1;
		if (!witness(a, n))
			return false;
	}
	return true;
}

LL gcd(LL a, LL b)
{ // 这里的gcd和一般的gcd不一样
	if (a == 0)
	{ // pollard_rho的需要
		return 1;
	}
	if (a < 0)
	{ // 可能有负数
		return gcd(-a, b);
	}
	while (b)
	{
		LL t = a % b;
		a = b;
		b = t;
	}
	return a;
}

LL pollard_rho(LL n, LL c)
{                    // 找因子
	LL i = 1, k = 2; // 用来判断是否成环
	LL xx = rand() % n, y = xx;
	while (1)
	{
		i++;
		xx = (mul(xx, xx, n) + c) % n;
		LL d = gcd(y - xx, n);
		if (1 < d && d < n)
		{ // 找到一个因数
			return d;
		}
		if (y == xx)
		{ // 出现循环，那么查找失败
			return n;
		}
		if (i == k)
		{ // 相当一个优化？
			y = xx;
			k <<= 1;
		}
	}
}

void find(LL n)
{ // 通过因数来找质因子
	if (miller_rabin(n))
	{
		fac[cnt++] = n; // 记录质因子
		return;
	}
	LL p = n;
	while (p >= n)
		p = pollard_rho(p, rand() % (n - 1) + 1); //如果转了一圈还是p那么继续
	find(p);
	find(n / p);
}

int main()
{
	srand(251);
	LL a, b;
	cin>>a>>b;
    if(a==1||b==1){
        cout<<1;
        return 0;
    }
	if (miller_rabin(a))
	{
		if (b % a == 0)
			cout << 2;
		else
			cout << 1;
		return 0;
	}
	if (miller_rabin(b))
	{
		if (a % b)
			cout << 2;
		else
			cout << 1;
		return 0;
	}
	cnt = 0;
	find(a);
	LL fa[1001];
	memcpy(fa, fac, sizeof(fac));
	sort(fa, fa + cnt);
	int ss = cnt;
	cnt = 0;
	find(b);
	sort(fac, fac + cnt);
	int ans = 0;
	for (int i = 0; i < ss; i++) {
		if (i && fa[i] == fa[i - 1])continue;
		for (int j = 0; j < cnt; j++) {
			if (j && fac[j] == fac[j - 1])continue;
			if (fac[j] == fa[i])ans++;
		}
	}
	cout << ans+1;
	return 0;
}

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

int main(){
  ll A,B; cin >> A >> B;
  if(A<B) swap(A,B);
  ll y = gcd(A,B);
  ll yy = y;
  ll x = 2;
  ll ans = 1;
  while(x*x<=y&&yy!=1){
    if(yy%x==0){
      ans++;
      while(yy%x==0) yy /= x;
    }
    x++;
  }
  if(yy!=1) ans++;
  cout << ans << endl;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#define CLR(x) memset((x), false, sizeof(x))
const int MAXD = 12801;
const int MAXN = 81;
int  A[2][MAXN][MAXN];
bool   dp[MAXN][MAXN][MAXD];
int H, W;

int solve() {
  CLR(dp);
  dp[0][0][0] = true;
  dp[0][1][0] = true;
  dp[1][0][0] = true;
  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      for (int k = 0; k < MAXD; ++k) {
        int d = std::abs(A[0][i][j] - A[1][i][j]);
        int nk1 = k + d;
        if (nk1 < MAXD) {
          dp[i][j][k] |= dp[i-1][j][nk1] | dp[i][j-1][nk1];
        }
        int nk2 = std::abs(k - d);
        dp[i][j][k] |= dp[i-1][j][nk2] | dp[i][j-1][nk2];
      }
    }
  }
  for (int k = 0; k < MAXD; ++k) {
    if (dp[H][W][k]) {
      return k;
    }
  }
  return -1;
}

int main() {
  scanf(" %d%d", &H, &W);
  for (int k = 0; k < 2; ++k) {
    for (int i = 1; i <= H; ++i) {
      for (int j = 1; j <= W; ++j) {
        scanf("%d", &A[k][i][j]);
      }
    }
  }
  printf("%d\n", solve());
  return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W)), B(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> A.at(i).at(j);
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> B.at(i).at(j);
        }
    }

    vector<vector<int>> d(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            d.at(i).at(j) = abs(A.at(i).at(j) - B.at(i).at(j));
        }
    }

    auto to_id = [&](int i, int j) {
        return i * W + j;
    };
    vector<vector<bool>> dp(H * W, vector<bool>(80 * 160 + 1));
    dp.at(to_id(0, 0)).at(d.at(0).at(0)) = true;
    for (int i = 1; i < H; i++)
    {
        for (int k = 0; k < 80 * 160 + 1; k++)
        {
            if (dp.at(to_id(i - 1, 0)).at(k))
            {
                dp.at(to_id(i, 0)).at(abs(k + d.at(i).at(0))) = true;
                dp.at(to_id(i, 0)).at(abs(k - d.at(i).at(0))) = true;
            }
        }
    }
    for (int j = 1; j < W; j++)
    {
        for (int k = 0; k < 80 * 160 + 1; k++)
        {
            if (dp.at(to_id(0, j - 1)).at(k))
            {
                dp.at(to_id(0, j)).at(abs(k + d.at(0).at(j))) = true;
                dp.at(to_id(0, j)).at(abs(k - d.at(0).at(j))) = true;
            }
        }
    }
    for (int i = 1; i < H; i++)
    {
        for (int j = 1; j < W; j++)
        {
            for (int k = 0; k < 80 * 160 + 1; k++)
            {
                if (dp.at(to_id(i - 1, j)).at(k))
                {
                    dp.at(to_id(i, j)).at(abs(k + d.at(i).at(j))) = true;
                    dp.at(to_id(i, j)).at(abs(k - d.at(i).at(j))) = true;
                }
                if (dp.at(to_id(i, j - 1)).at(k))
                {
                    dp.at(to_id(i, j)).at(abs(k + d.at(i).at(j))) = true;
                    dp.at(to_id(i, j)).at(abs(k - d.at(i).at(j))) = true;
                }
            }
        }
    }
    for (int k = 0; k < 80 * 160 + 1; k++)
    {
        if (dp.at(to_id(H - 1, W - 1)).at(k))
        {
            cout << k << endl;
            break;
        }
    }
    return 0;
}


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

#define V(a) a.begin(), a.end()
typedef set<int> s;

int main()
{
	s a[2], C;

	for (auto &i : a) {
		int n, x;
		cin >> n;
		while (n--) {
			cin >> x;
			i.insert(x);
		}
	}

	set_intersection(V(a[0]), V(a[1]), inserter(C, C.end()));

	cout << C.size() << endl;
}

#include <iostream>
using namespace std;

int main() {

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

    int q;
    cin >> q;
    int *T = new int[q];
    for (int i = 0; i < q; ++i) {
        cin >> T[i];
    }

    int count = 0;
    for (int i = 0; i < q; ++i) {
        for (int j = 0; j < n; ++j) {
            if (S[j] == T[i]) {
                ++count;
                break;
            }
        }
    }

    cout << count << endl;

    delete[] S;
    delete[] T;
    return 0;
}


#include <iostream>
#include <cctype>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <complex>
#include <cstring>
#include <set>
using namespace std;
#define loop(i,a,b) for(int i=a; i<b; i++)
#define rep(i,a) loop(i,0,a)

int input[1111][3], res[1111];

int main(){
    int a,b,c;
    while(cin>>a>>b>>c && a){
        int n; cin>>n;
        rep(i,n){
            rep(j,3)cin >> input[i][j];
            cin>>res[i];
        }

        bool ok[1111]={}, bad[1111]={};
        rep(k,2){
            rep(i,n){
                int a=0,b=0;
                int x,y,z;
                tie(x,y,z)=tie(input[i][0],input[i][1],input[i][2]);
                for(int j : {x,y,z}){
                    if(ok[j])a++;
                    if(bad[j])b++;
                }
                if(res[i]){
                    if(a!=3){
                        ok[x]=ok[y]=ok[z]=true;
                    }
                }else{
                    if(a==2 && b!=1){
                        for(int j : {x,y,z}){
                            if(!ok[j])bad[j]=true;
                        }
                    }
                }
            }
        }
        for(int i=1;i<=a+b+c;i++){
            if(ok[i] && !bad[i])cout<<1;
            else if(!ok[i] && bad[i])cout<<0;
            else cout<<2;
            cout<<endl;
        }
    }
}

#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int a, b, c, n;
        cin >> a >> b >> c >> n;
        if(a == 0)
            return 0;

        vector<vector<int> > check(n, vector<int>(4));
        for(int i=0; i<n; ++i){
            for(int j=0; j<4; ++j)
                cin >> check[i][j];
        }

        vector<int> quality(a+b+c+1, 2);
        for(int i=0; i<n; ++i){
            if(check[i][3] == 1){
                quality[check[i][0]] = 1;
                quality[check[i][1]] = 1;
                quality[check[i][2]] = 1;
            }
        }
        for(int i=0; i<n; ++i){
            if(check[i][3] == 0){
                if(quality[check[i][0]] == 1 && quality[check[i][1]] == 1)
                    quality[check[i][2]] = 0;
                if(quality[check[i][1]] == 1 && quality[check[i][2]] == 1)
                    quality[check[i][0]] = 0;
                if(quality[check[i][2]] == 1 && quality[check[i][0]] == 1)
                    quality[check[i][1]] = 0;
            }
        }

        for(int i=1; i<=a+b+c; ++i)
            cout << quality[i] << endl;
    }
}


#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int dp[12][9 * mx6], g, d, p[12], c[12];

int stt(int id, int S)
{
    if(id > d){
        if(S < g)
            return 1e7;
        return 0;
    }

    if(dp[id][S] != -1)
        return dp[id][S];

    int ans = INT_MAX;
    for(int i = 0; i < p[id]; i++){
        ans = min(ans, i + stt(id + 1, S + i * id * 100));
    }

    ans = min(ans, p[id] + stt(id + 1, S + id * 100 * p[id] + c[id]));

    return dp[id][S] = ans;
}

int main()
{
    mem(dp, -1);
    cin >> d >> g;

    for(int i = 1; i <= d; i++)
        cin >> p[i] >> c[i];

    cout << stt(1, 0) << '\n';
    return 0;
}

#include <bits/stdc++.h>

int main(){
    long long D, G;
    std::cin >> D >> G;
    G /= 100;
    std::vector< int > P(D);
    std::vector< int > C(D);
    for(int i=0; i<D; i++){
        std::cin >> P[i] >> C[i];
        P[i];
        C[i] /= 100;
    }

    std::vector< std::vector< int > > dp(D+1, std::vector< int >(G+1, 1e8));
    dp[0][0] = 0;

    for(int i=1; i<=D; i++){
        std::vector< int > cur(G+1, 1e8);
        cur[0] = 0;
        for(int j=1; j<=G; j++){
            if(i * P[i-1] + C[i-1] < j){
                break;
            }else if(i * P[i-1] < j){
                cur[j] = P[i-1];
            }else{
                cur[j] = j / i + (j % i != 0);
            }
        }
        int index_a1 = 1, index_a2 = 0, index_b1 = 0, index_b2 = 1;
        dp[i][0] = 0;
        while(index_a1 + index_a2 <= G){
            int a = dp[i-1][index_a1] + cur[index_a2];
            int b = dp[i-1][index_b1] + cur[index_b2];
            if(a > b){
                dp[i][index_a1 + index_a2] = b;
            }else{
                dp[i][index_a1 + index_a2] = a;
            }

            if(index_a1 == G || dp[i-1][index_a1+1] >= 1e8){
                index_a2++;
            }else{
                index_a1++;
            }

            if(index_b2 == G || cur[index_b2+1] >= 1e8){
                index_b1++;
            }else{
                index_b2++;
            }
        }
    }

    std::cout << dp[D][G] << std::endl;

    return 0;

}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll ac(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	rep(i, 0, n)cin >> v[i];
	int score, M = 0;
	rep(g, 0, min(n, k) + 1) {
		rep(l, 0, g + 1) {
			vector<int> s;
			rep(i, 0, n) {
				if (i < l || i >= n - g + l)s.push_back(v[i]);
			}
			sort(all(s));
			int p = 0, m = min(k - g, (int)s.size());
			for (; p < m; p++)if (s[p] > 0)break;
			score = 0;
			for (; p < s.size(); p++)score += s[p];
			M = max(score, M);
			s.erase(all(s));
		}
	}
	printf("%d\n", M);
	return 0;
}

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

const int N = 50 + 5, mod = 1e9 + 7;
int n, k;
int a[N], dp[N][N][102];

int solve(int l, int r, int left)
{
    if (l > r)
        return 0;
    if (dp[l][r][left] != -1)
        return dp[l][r][left];
    int ans = 0;
    if (a[l] < 0)
    {
        if (left > 0)
            ans = max(ans, solve(l + 1, r, left - 1) + a[l]);
        if (left > 1)
            ans = max(ans, solve(l + 1, r, left - 2));
    }
    if (a[l] >= 0 && left > 0)
        ans = max(ans, solve(l + 1, r, left - 1) + a[l]);
    if (a[r] < 0)
    {
        if (left > 0)
            ans = max(ans, solve(l, r - 1, left - 1) + a[r]);
        if (left > 1)
            ans = max(ans, solve(l, r - 1, left - 2));
    }
    if (a[r] >= 0 && left > 0)
        ans = max(ans, solve(l, r - 1, left - 1) + a[r]);
    return dp[l][r][left] = ans;
}

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset(dp, -1, sizeof dp);
    cout << solve(0, n - 1, k);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){return b%a ? gcd(b%a,a) : a;}
int main(){
    int N;
    cin>>N;
    int a,b,c;
    cin>>a>>b;
    if(N==3) cin>>c;
    int tmp=gcd(a,b);
    if(N==3) tmp=gcd(tmp,c);
    for(int i=1;i<=tmp;i++){
        if(tmp%i==0) cout<<i<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rg register
#define rep(i,a,b) for (rg int i=a;i<=b;i++)
#define per(i,a,b) for (rg int i=b;i>=a;i--)
#define pb push_back
#define lowbit(x) (x&(-x))
#define mk make_pair
#define VI vector<int>
#define pii pair<int,int>
#define pLL pair<long long,long long>
#define fi first
#define se second
#define il inline
#define ll long long
#define db double
#define ld long double
#define inf 0x3f3f3f3f
#define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<15,stdin),p1==p2)?EOF:*p1++)
char buf[1<<15],*p1 = buf,*p2 = buf;
inline ll read(){
    #define num ch-'0'
    char ch;bool flag=0;ll res;
    while(!isdigit(ch=getc()))
    (ch=='-')&&(flag=true);
    for(res=num;isdigit(ch=getc());res=res*10ll+num);
    (flag)&&(res=-res);
    #undef num
    return res;
}
inline void write(ll x){
	if (x < 0) x = ~x + 1ll, putchar('-');
	if (x > 9) write(x / 10ll);
	putchar(x % 10ll + '0');
}
#define mid ((l + r)>>1)
#define ls (x<<1)
#define rs ((x<<1)|1)
#undef mid
#undef ls
#undef rs
ll gcd(ll a,ll b) {return b == 0?a:gcd(b,a%b);}
void solve()
{
	ll a = read(),b = read();
	ll c = gcd(a,b);
	int tot = 1;
	for(ll i =2 ;i*i<=c;i++)
	{
		if(c%i==0)
		{
			while(c%i==0) c/=i;
			tot++;
		}
	}
	if(c>1) tot++;
	cout<<tot<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("data.txt","r",stdin);
	#endif
//	int T = read();
//	while(T--)
	solve();
}


#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

class Dice{

private:

public:

  int num[6];

  void roll(char c){
    int b;
    if(c == 'S'){
      b = num[0];
      num[0] = num[4];
      num[4] = num[5];
      num[5] = num[1];
      num[1] = b;
    }
    if(c == 'W'){
      b = num[0];
      num[0] = num[2];
      num[2] = num[5];
      num[5] = num[3];
      num[3] = b;
    }
    if(c == 'N'){
      b = num[0];
      num[0] = num[1];
      num[1] = num[5];
      num[5] = num[4];
      num[4] = b;
    }
    if(c == 'E'){
      b = num[0];
      num[0] = num[3];
      num[3] = num[5];
      num[5] = num[2];
      num[2] = b;
    }
  }
};

bool isSame(Dice d1, Dice d2){
  int top = d1.num[0], front = d1.num[1];
  if(d2.num[2] == front || d2.num[3] == front) d2.roll('W');
  int cnt = 0;
  while(d2.num[1] != front){
    d2.roll('S');
    if(++cnt == 4) return false;
  }
  cnt = 0;
  while(d2.num[0] != top){
    d2.roll('W');
    if(++cnt == 4) return false;
  }
  for(int i=2;i<6;i++){
    if(d1.num[i] != d2.num[i]){
      return false;
    }
  }
  return true;
}

bool isAllDiff(vector <Dice> d, int n){
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      if(isSame(d[i], d[j])){
	return false;
      }
    }
  }
  return true;
}

int main(){
  vector <Dice> vec;
  Dice d;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<6;j++){
      cin >> d.num[j];
    }
    vec.push_back(d);
  }

  if(isAllDiff(vec, n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
void dice1();
void dice2();
void dice3();
void dice4();
class DICE{
	int face[6],a;
public:
	bool operator==(const DICE&di)const{
		int cont=0;
		for(int i=0;i<6;++i){
			if(face[i]==di.face[i]){
				cont++;
			}
		}
		if(cont==6){
			return true;
		}
		else{
			return false;
		}
	}
	bool operator!=(const DICE&di)const{
		return !(*this==di);
	}
	void set(int&f,int&f1,int&f2,int&f3,int&f4,int&f5){
		face[0]=f;face[1]=f1;face[2]=f2;face[3]=f3;face[4]=f4;face[5]=f5;
	}
	void N(){
		a=face[0];
		face[0]=face[1];
		face[1]=face[5];
		face[5]=face[4];
		face[4]=a;
	}
	void E(){
		a=face[0];
		face[0]=face[3];
		face[3]=face[5];
		face[5]=face[2];
		face[2]=a;
	}
	void S(){
		a=face[0];
		face[0]=face[4];
		face[4]=face[5];
		face[5]=face[1];
		face[1]=a;
	}
	void W(){
		a=face[0];
		face[0]=face[2];
		face[2]=face[5];
		face[5]=face[3];
		face[3]=a;
	}
	void output(){
		cout<<face[0]<<endl;
	}
	int up(){
		return face[0];
	}
	void turn(){
		a=face[1];
		face[1]=face[3];
		face[3]=face[4];
		face[4]=face[2];
		face[2]=a;
	}
	int front(){
		return face[1];
	}
	int right(){
		return face[2];
	}
	void allout(){
		for(int i=0;i<6;++i){
			cout<<face[i]<<" ";
		}
		cout<<endl;
	}
	void toupper(int n){
		if(n<=3){
			a=face[0];
			face[0]=face[1];
			face[1]=face[5];
			face[5]=face[4];
			face[4]=a;
		}
		else if(n==4){
			a=face[0];
			face[0]=face[3];
			face[3]=face[5];
			face[5]=face[2];
			face[2]=a;
		}
		else if(n==5){
			a=face[0];
			face[0]=face[3];
			face[3]=face[5];
			face[5]=face[2];
			face[2]=a;
			a=face[0];
			face[0]=face[3];
			face[3]=face[5];
			face[5]=face[2];
			face[2]=a;
		}

	}
};
bool judge(DICE,DICE);
int main(){
	dice4();
	return 0;
}
void dice1(){
	DICE a;
	int d[6];string str;
	for(int i=0;i<6;++i){
		cin>>d[i];
	}
	a.set(d[0],d[1],d[2],d[3],d[4],d[5]);
	getline(cin,str);
	getline(cin,str);
	for(int i=0;i<str.size();++i){
		if(str[i]=='E'){
			a.E();
		}
		else if(str[i]=='S'){
			a.S();
		}
		else if(str[i]=='W'){
			a.W();
		}
		else if(str[i]=='N'){
			a.N();
		}
	}
	a.output();
	return;
}
void dice2(){
	DICE a;
	int d[6],p,u;
	for(int i=0;i<6;++i){
		cin>>d[i];
	}a.set(d[0],d[1],d[2],d[3],d[4],d[5]);
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>p>>u;
		int k=0;
		while(1){
			k++;
			if(k<=5){
				a.E();
			}
			else{
				a.N();
			}
			if(p==a.up()){
				break;
			}
		}
		k=0;
		while(1){
			k++;
			a.turn();
			if(u==a.front()){
				break;
			}
		}
		cout<<a.right()<<endl;
	}
	return;
}
void dice3(){
	DICE a,b;
	int d[6][2];
	for(int i=0;i<2;++i){
		for(int j=0;j<6;++j){
			cin>>d[j][i];
		}
	}
	a.set(d[0][0],d[1][0],d[2][0],d[3][0],d[4][0],d[5][0]);
	b.set(d[0][1],d[1][1],d[2][1],d[3][1],d[4][1],d[5][1]);
	if(judge(a,b)){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}
bool judge(DICE a,DICE b){
	bool bo1=false,bo2=false;
	for(int i=0;i<6;++i){
		b.toupper(i);
		for(int j=0;j<4;++j){
			if(a==b){
				return true;
			}
			b.turn();
		}

	}
	return false;
}
void dice4(){
	int n,d[6][101];
	DICE a[101];
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<6;++j){
			cin>>d[j][i];
		}
	}
	for(int i=0;i<n;++i){
		a[i].set(d[0][i],d[1][i],d[2][i],d[3][i],d[4][i],d[5][i]);
	}
	for(int i=0;i<n-1;++i){
		for(int j=i+1;j<n;++j){
			if(judge(a[i],a[j])){
				cout<<"No"<<endl;
				return ;
			}
			else {

			}
		}
	}
	cout<<"Yes"<<endl;
	return ;
}


#include<iostream>
#include<cmath>
#include<stdio.h>
#include<string.h>
using namespace std;

struct node
{
    double x,y;
};

double PI=acos(-1.0);
int n;
node p[111];
double ans[111];

void merge(double &from,double &to,double ff,double tt)
{
    if(from>ff)
    {
        swap(from,ff);
        swap(to,tt);
    }

    if(to==-2.0*PI)
    {
        from=ff;to=tt;
        return ;
    }

    double f0,t0;

    f0=max(from,ff);
    t0=min(to,tt);

    if(f0<=t0)
    {
         from=f0;to=t0;
         return ;
    }

    if(tt>PI)
    {
        ff-=2.0*PI;
        tt-=2.0*PI;
        f0=max(from,ff);
        t0=min(to,tt);
    }

    from=f0;to=t0;
    return ;
}

int main()
{
    int i,j,k;
    double from,to;

    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>p[i].x>>p[i].y;
    }
    for(i=1;i<=n;i++)
    {
        from=-PI*4.0;
        to=-PI*2.0;

        for(j=1;j<=n;j++)
        {
            if(i==j)continue;

            node l;
            l.x=p[j].x-p[i].x;
            l.y=p[j].y-p[i].y;

            double e=atan2(l.x,l.y);
            //cout<<atan2(0,-1)<<endl;
            e+=PI/2.0;
            if(e>PI)e-=2.0*PI;
            double ff,tt;
            ff=e;tt=e+PI;

            //cout<<ff<<' '<<tt<<"   %%%"<<endl;
            merge(from,to,ff,tt);
            //cout<<from<<' '<<to<<endl;
        }

        cout.precision(7);
        cout.setf(ios::fixed);
        cout<<max((to-from)/(PI*2.0),0.0)<<endl;
    }
    return 0;
}

#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
#define double long double
using namespace std;
const double pi=acos(-1);
struct poLL {LL  x,y,num;}p[110],a[110];
double ans[110];
LL multi(poLL  p1,poLL  p2,poLL  p0)
{
	LL x1=p1.x-p0.x,y1=p1.y-p0.y;
	LL x2=p2.x-p0.x,y2=p2.y-p0.y;
	return x1*y2-x2*y1;
}
LL  n,top=0,sta[110];
LL  dis(poLL  a,poLL  b) {return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);}
bool cmp(poLL a,poLL b)
{
	LL t1=multi(b,a,p[1]);
	return t1==0?dis(p[1],a)<dis(p[1],b):t1>0;
}
void solve()
{
	for(LL  i=2;i<=n;i++)
		if((p[1].x==p[i].x)?(p[i].y<p[1].y):(p[i].x<p[1].x)) swap(p[1],p[i]);
	sort(p+2,p+n+1,cmp);
	sta[++top]=1;
	for(LL  i=2;i<=n;i++)
	{
		while(top>1&&multi(p[sta[top]],p[sta[top-1]],p[i])<0) top--;
		sta[++top]=i;
	}
}
double get(poLL  p1,poLL  p2,poLL  p0)
{
	LL x1=p1.x-p0.x,y1=p1.y-p0.y;
	LL x2=p2.x-p0.x,y2=p2.y-p0.y;
	return (double)(x1*x2+y1*y2)/(sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2));
}
void calc()
{
	if(top==0) for(LL  i=1;i<=top;i++) ans[p[sta[i]].num]=0.5;
	else
	{
		sta[0]=sta[top];sta[top+1]=sta[1];
		for(LL  i=1;i<=top;i++)
		{
			double tmp=get(p[sta[i-1]],p[sta[i+1]],p[sta[i]]);
			double s=pi-acos(tmp);
			ans[p[sta[i]].num]=s/(pi*2);
		}
	}
}
int  main()
{
	scanf("%lld",&n);
	for(LL  i=1;i<=n;i++) scanf("%lld %lld",&p[i].x,&p[i].y),p[i].num=i;
	if(n==1) return puts("1.000000000000"),0;
	solve();calc();
	for(LL i=1;i<=n;i++) printf("%.9Lf\n",ans[i]);
}


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

typedef long long ll;

int main() {
	ll l,r,ans=2e9;
	cin >> l >> r;
	if (r-l+1 <= 2019) {
		for (ll i=l; i<r; i++) {
			for (ll j=i+1; j<=r; j++) {
				ans = min(ans, ((i%2019)*(j%2019))%2019);
			}
		}
		cout << ans << '\n';
	} else {
		cout << 0 << '\n';
	}
	return 0;
}

#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  int N, K; cin >> N >> K;
  int x[N]; rep(i,N) cin >> x[i];
  int ans = 1000000000;
  rep(i,N-K+1){
    int MAX = x[i+K-1], MIN = x[i];
    int tmp;
    if (MIN > 0 || MAX<0 ){
      tmp = max(abs(MIN), abs(MAX));
    }
    else {
      tmp = MAX - MIN + min(MAX, abs(MIN));
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;

  // cout << fixed << setprecision(10);

  return 0;
}


/*
 * d.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 1000000;
const int MAX_M = 20;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N], gs[MAX_M];

/* subroutines */
int insertion_sort(int as[], int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; i++) {
    int v = as[i];
    int j = i - g;
    while (j >= 0 && as[j] > v) {
      as[j + g] = as[j];
      j = j - g;
      cnt++;
    }
    as[j + g] = v;
  }
  return cnt;
}

int shell_sort(int as[], int n, int gs[], int m) {
  int cnt = 0;
  for (int i = 0; i < m; i++)
    cnt += insertion_sort(as, n, gs[i]);
  return cnt;
}

/* main */

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

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

  int g;
  for (g = 1; g <= n; g <<= 1);

  int m = 0;
  for (g >>= 1; g > 0; g >>= 1, m++) gs[m] = g;

  int cnt = shell_sort(as, n, gs, m);

  printf("%d\n", m);
  for (int i = 0; i < m; i++) {
    if (i) putchar(' ');
    printf("%d", gs[i]);
  }
  putchar('\n');
  printf("%d\n", cnt);

  for (int i = 0; i < n; i++) printf("%d\n", as[i]);

  return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
inline int rd(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e5+5, oo = 0x3f3f3f3f;
int n, p, q, l[N], r[N], ans; pii v[N];
int main()
{
    n = rd(), p = oo; for(int i = 1; i <= n; ++i) l[i] = rd(), r[i] = rd(), p = min(p, r[i]), q = max(q, l[i]);
    for(int i = 1; i <= n; ++i) v[i].fi = p-l[i]+1, v[i].se = r[i]-q+1, ans = max(ans, r[i]-l[i]+1+max(p-q+1, 0));
    sort(v+1, v+n+1); for(int i = 1, w = oo; i < n; ++i) w = min(w, v[i].se), ans = max(ans, w+v[i+1].fi);
    printf("%d\n", ans);
    return 0;
}


// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,ko;
    ll x,y,w,z;
    char hoge,fuga;
    cin>>n;
    b=n;
    while(b>0){
        sum+=b%10;
        b/=10;
    }
    if(n%sum) No;
    else Yes;

    return 0;
}

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

int main() {
  int N=0, a=0, b=0, c=10;
  cin >> N;

  a = N % c;
  for(int i=0; i<8; i++){
    if(c > N){
      break;
    }
    b = N / c;
    a += b % 10 ;
    c = c * 10;
  }

  if(N % a == 0){
    cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
}


#include <bits/stdc++.h>

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    string s;
    cin >> s;
    if (s.length() == 2)
    {
        cout << s << endl;
        return;
    }
    reverse(all(s));
    cout << s << endl;
}
int main(void)
{
    solve();
}

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

using namespace std;
double condition = 0.0;

void func()
{
	int X;
	cin >> X;
	int Y, Z;
	Y = X / 500;
	Z = (X % 500) / 5;

	cout << 1000 * Y + Z * 5 << endl;
}

int main() {
//	while(1)
	func();
	return 0;
}


#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()

int main() {
    int R;
    cin >> R;
    string s;
    if(R < 1200) s = "ABC";
    else if(R < 2800) s = "ARC";
    else s = "AGC";
    cout << s << endl;
}

#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    cout << (N - 2) * 180 << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
const int N=101;
char mat[N][N];
short f[N][N][N][N],sum[N][N];
inline int asksum(int x1,int x2,int y1,int y2){
	return x1<=x2&&y1<=y2?sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1]:0;
}
int main(){
	int n=ni,m=ni,ex,ey;
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;i++){
		scanf("%s",mat[i]+1);
		for(int j=1;j<=m;j++){
			sum[i][j]=(mat[i][j]=='o')+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			if(mat[i][j]=='E'){
				ex=i,ey=j;
			}
		}
	}
	for(int i=ex;i>=1;i--){
		for(int j=ex;j<=n;j++){
			for(int k=ey;k>=1;k--){
				for(int l=ey;l<=m;l++){
					short &F=f[i][j][k][l]=0;
					int xs=max(1+(j-ex),i),xt=min(n-(ex-i),j);
					int ys=max(1+(l-ey),k),yt=min(m-(ey-k),l);
					if(i<ex)apmax(F,f[i+1][j][k][l]+asksum(xs,i,ys,yt));
					if(j>ex)apmax(F,f[i][j-1][k][l]+asksum(j,xt,ys,yt));
					if(k<ey)apmax(F,f[i][j][k+1][l]+asksum(xs,xt,ys,k));
					if(l>ey)apmax(F,f[i][j][k][l-1]+asksum(xs,xt,l,yt));
				}
			}
		}
	}
	printf("%d\n",(int)f[1][n][1][m]);
	return 0;
}

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 1000010

int dp[SIZE][2];

int main() {
  char S[SIZE];

  scanf("%s", S);
  int N = strlen(S);

  for (int i = 0; i <= N; i++)
    dp[i][0] = dp[i][1] = INF;

  dp[0][0] = 0;
  dp[0][1] = 1;

  for (int i = 0; i < N; i++) {
    int p = S[i] - '0';

    dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + p);
    dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + 10 - p);

    dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + p + 1);
    dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + 10 - p - 1);
  }

  cout << dp[N][0] << endl;

  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct UnionFind
{
    void init(int n)
    {
        mN = n;
        mNodeTbl.resize(mN);
        REP(i, mN)
        {
            mNodeTbl[i] = i;
        }
    }
    int find(int x)
    {
        if (x == mNodeTbl[x])
            return x;
        return mNodeTbl[x] = find(mNodeTbl[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unit(int x, int y)
    {
        x = find(x);
        y = find(y);
        mNodeTbl[x] = y;
    }

    int mN;
    vector<int> mNodeTbl;
};

struct Edge
{
    int a;
    int b;
    ll w;
};

Edge e[100005];

int main()
{
    int V, E;
    cin >> V >> E;
    REP(i, E)
    {
        cin >> e[i].a >> e[i].b >> e[i].w;
    }
    sort(e, e + E, [](Edge a, Edge b) { return a.w < b.w; });
    UnionFind uf;
    uf.init(V);
    ll cost = 0;
    REP(i, E)
    {
        Edge t = e[i];
        if (uf.same(t.a, t.b))
            continue;
        cost += t.w;
        uf.unit(t.a, t.b);
    }
    cout << cost << endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second

typedef pair<int,int> ii;
typedef pair<int,ii> iii;

class UnionFindDS{
private:
	vector<int> p, h, sz;	// parent, height (rank), size
	int num;
public:
	UnionFindDS(int N){
		p.assign(N,0); for (int i=0; i<N; i++) p[i] = i;
		h.assign(N,0); sz.assign(N,1);
		num = N;
	}
	int numSets(){ return num; }
	int findSet(int i){ return p[i] == i ? i : p[i] = findSet(p[i]); }
	int sizeSet(int i){ return sz[findSet(i)]; }
	bool isSameSet(int i, int j){ return findSet(i) == findSet(j); }
	void unionSet(int i, int j){
		int x = findSet(i), y = findSet(j);
		if (x == y) return;

		num--;
		if (h[x] > h[y]){ p[y] = x; sz[x] += sz[y]; }
		else			{ p[x] = y; sz[y] += sz[x]; h[y] += (h[y] == h[x]); }
	}
};

priority_queue< iii,vector<iii>,greater<iii> > pq;

int main(){

	ios_base::sync_with_stdio(0);

	int V, E;
	cin >> V >> E;

	int u, v, w;
	for (int i=0; i<E; i++){
		cin >> u >> v >> w;

		pq.push(iii(w,ii(u,v)));
	}

	UnionFindDS uf(V);

	int sum = 0;
	while (uf.numSets() > 1 && !pq.empty()){
		iii front = pq.top(); pq.pop();

		u = front.se.fi; v = front.se.se; w = front.fi;

		if (uf.isSameSet(u,v)) continue;

		uf.unionSet(u,v); sum += w;
	}

	if (uf.numSets() > 1) cout << -1  << endl;		// impossible to form spanning tree
	else 				  cout << sum << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 5;
const int LG = 18;
int up[N][LG];
int arr[N];
int n, l, q;

void run_case() {
    cin >> n;
    loop(i, n)cin >> arr[i];
    cin >> l >> q;

    rloop(i, n - 1) {
        int par = i == n - 1 ? n - 1 : (upper_bound(arr + i, arr + n, arr[i] + l) - arr - 1);
        up[i][0] = par;
        for (int k = 1; k < LG; ++k)
            up[i][k] = up[up[i][k - 1]][k - 1];
    }

    while (q--) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a > b)swap(a, b);
        int ans = 1;
        for (int i = LG - 1; i >= 0; i--) {
            if (up[a][i] < b) {
                a = up[a][i];
                ans += 1 << i;
            }
        }
        cout << ans << endl;
    }
}

int main() {

#ifndef ONLINE_JUDGE
//    freopen("in.in", "r", stdin);
//    freopen("out.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
//    cin >> T;
    while (T--)run_case();

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int x[MAXN], st[MAXN][18];
int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
    int L, Q; scanf("%d%d", &L, &Q);
    // memset(st, 0x3f3f3f3f, sizeof(st));
    for (int i = 1; i <= n; i++)
        st[i][0] = min(n, (int)(upper_bound(x + 1, x + 1 + n, x[i] + L) - x - 1));

    for (int j = 1; j < 18; j++)
        for (int i = 1; i <= n; i++)
            st[i][j] = st[st[i][j - 1]][j - 1];
    while (Q--)
    {
        int l, r; scanf("%d%d", &l, &r);
        if (l > r) swap(l, r);
        int res = 0;
        for (int j = 17; j >= 0; j--)
            if (st[l][j] < r) res += (1 << j), l = st[l][j];
        printf("%d\n", res + 1);
    }
    return 0;
}


#include <iostream>
using namespace std;

int main(){
    while(1){
        int a, b, c, n, list[1001][4], parts[301], judge, defect;

        cin >> a >> b >> c >> n;
        if(a == 0 && b == 0 && c == 0){
            break;
        }

        for(int i = 1; i <= a + b + c; i++){
            parts[i] = 2;
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < 4; j++){
                cin >> list[i][j];
            }
            if(list[i][3] == 1){
                for(int k = 0; k < 3; k++){
                    parts[list[i][k]] = 1;
                }
            }
        }

        for(int i = 0; i < n; i++){
            if(!list[i][3]){
                judge = 0;
                for(int j = 0; j < 3; j++){
                    if(parts[list[i][j]] == 1){
                        judge++;
                    } else{
                        defect = j;
                    }
                }
                if(judge == 2){
                    parts[list[i][defect]] = 0;
                }
            }
        }

        for(int i = 1; i <= a + b + c; i++){
            cout << parts[i] << endl;
        }
    }

    return 0;
}

#include <stdio.h>
int main(){
	int i,n,pm,pj,pe;
	double avg,emav;
	char type;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d%d%d",&pm,&pe,&pj);
			avg = (pm+pe+pj) / 3.0;
			emav = (pm+pe) / 2.0;
			if(pm==100.0||pe==100.0||pj==100.0||emav>=90.0||avg>=80.0) type = 'A';
			else if(avg>=70.0) type = 'B';
			else if(avg>=50.0&&(pe>=80.0||pm>=80.0)) type = 'B';
			else type = 'C';
			printf("%c\n",type);
		}
		scanf("%d",&n);
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n, q;

struct segtree {
    static const llong inf = 1e18;
    llong offset, seg[1 << 19];

    segtree() : offset(0) {
        for (int i = 1 << 19; i--; ) seg[i] = inf;
    }

    void update(int i, int s, int e, int x, llong v) {
        if (s == e) {
            seg[i] = min(seg[i], v);
            return;
        }
        int m = (s + e) / 2;
        if (x <= m) update(i << 1, s, m, x, v);
        else update(i << 1 | 1, m + 1, e, x, v);
        seg[i] = min(seg[i << 1], seg[i << 1 | 1]);
    }

    void update(int x, llong v) {
        update(1, 1, n, x, v - offset);
    }

    llong query(int i, int s, int e, int x, int y) const {
        if (e < x || y < s) return inf;
        if (x <= s && e <= y) return seg[i];
        int m = (s + e) / 2;
        return min(query(i << 1, s, m, x, y), query(i << 1 | 1, m + 1, e, x, y));
    }

    llong query(int x, int y) const {
        return offset + query(1, 1, n, x, y);
    }

    llong getans(int i, int s, int e) const {
        if (s == e) return seg[i] + s;
        int m = (s + e) / 2;
        return min(getans(i << 1, s, m), getans(i << 1 | 1, m + 1, e));
    }

    llong getans() const {
        return getans(1, 1, n) + offset;
    }
} AP, AN, BP, BN;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int A, B, x, p;
    cin >> n >> q >> A >> B >> x;
    AP.update(B, abs(A - x) + B);
    AN.update(B, abs(A - x) - B);
    BP.update(A, abs(B - x) + A);
    BN.update(A, abs(B - x) - A);
    while (--q) {
        p = x;
        cin >> x;
        llong AxBp = min({ BP.query(x, n) - x, BN.query(1, x) + x });
        llong ApBx = min({ AP.query(x, n) - x, AN.query(1, x) + x });
        llong d = abs(x - p);
        AP.offset += d; AN.offset += d; BP.offset += d; BN.offset += d;
        AP.update(p, AxBp + p);
        AN.update(p, AxBp - p);
        BP.update(p, ApBx + p);
        BN.update(p, ApBx - p);
    }
    printf("%lld\n", min(AN.getans(), BN.getans()));
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int ll;
const int MAX=100000;
const int INFTY=1<<30;

int n,col[MAX],d[MAX];
vector<pair<int,int>> Q[MAX];//target,weight

void dijkstra(int s)
{
	priority_queue<pair<int,int>> PQ;//weight,id
	for(int i=0;i<n;i++)
	{
		d[i]=INFTY;
		col[i]=0;
	}
	d[s]=0;
	PQ.push(make_pair(0,s));
	col[s]=1;

	while(!PQ.empty())
	{
		pair<int,int> f=PQ.top();PQ.pop();
		int u=f.second;
		col[u]=2;
		if(d[u]<f.first*(-1))continue;
		for(int j=0;j<Q[u].size();j++)
		{
			int v=Q[u][j].first;
			if(col[v]==2)continue;
			if(d[u]+Q[u][j].second<d[v])
			{
				d[v]=d[u]+Q[u][j].second;
				PQ.push(make_pair(d[v]*(-1),v));
				col[v]=1;
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		if(d[i]==INFTY)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}

	return;
}

int main()
{
	cin>>n;
	int u;int m;cin>>m>>u;
	int s,t,w;
	for(int i=0;i<m;i++)
	{
		cin>>s>>t>>w;
		Q[s].push_back(make_pair(t,w));
	}
	dijkstra(u);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

i64 MOD = 998244353;

long long inv_mod(long long a, long long m = MOD) {
  long long b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}

i64 fact[101010];
i64 inv[101010];

void init() {
  fact[0] = 1;
  for(int i = 1;i < 101010;i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  inv[101010 - 1] =  inv_mod(fact[101010 - 1]) % MOD;
  for(int i = 101010 - 1;i >= 1;i--) {
    inv[i - 1] = inv[i] * i % MOD;
  }
}

i64 comp(i64 n, i64 k) {
  if(n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * inv[k] % MOD * inv[n - k] % MOD;
}

int main() {
  init();
  i64 K, N;
  cin >> K >> N;

  for(int i = 2; i <= 2 * K;i++) {
    i64 p = i;
    if(i > K + 1) p = (K + 1) * 2 - p;
    p /= 2;

    i64 ans = 0;

    for(int j = 0;j <= p;j++) {
      auto res = comp(p, j) * comp(K + N - 2 * j - 1, N - 2 * j) % MOD;
      if(j & 1) ans = (ans - res % MOD + MOD) % MOD;
      else ans = (ans + res) % MOD;
    }
    cout << ans << endl;
  }
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

map<ll, ll> prime_factor(ll n) {
      map< ll, ll > ret;
      for(ll i = 2; i * i <= n; i++) {
          while(n % i == 0) {
              ret[i]++;
              n /= i;
          }
      }
      if(n != 1) ret[n] = 1;
      return ret;
}

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll n, m;
    cin >> n >> m;
    map<ll,ll> mp = prime_factor(m);
    COMinit();
    ll ans = 1;

    for(auto v : mp){
        ll p = v.second;
        ans *= COM(n+p-1, p);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int gcd(int a, int b){
	while(b){
		int r = a % b;
		a = b;
		b = r;
	}
	return a;
}

int main(){
	list<int> ls;
	list<int>::iterator it = ls.begin();

	int n, a, b, c;
	cin >> n >> a >> b >> c;
	a = gcd(a, b);
	if(n == 3) a = gcd(a, c);

	for(int i = 1; i * i <= a; ++i){
		if(a % i == 0){
			ls.insert(it, i);
			if(i * i < a) it = ls.insert(it, a / i);
		}
	}

	copy(ls.begin(), ls.end(), ostream_iterator<int>(cout, "\n"));
}

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

//#define PI 3.141592653589

using namespace std;

int main()
{
	int n;
	long seisuu[3];

	cin >> n;
	for (int i=0; i<n; i++) cin >> seisuu[i];
	sort(seisuu, seisuu+n);

	for (int i=1; i<=seisuu[0]; i++)
	{
		if (n == 2)
		{
			if (seisuu[0]%i==0 && seisuu[1]%i==0)
			{
				cout << i << endl;
			}
		} else {
			if (seisuu[0]%i==0 && seisuu[1]%i==0 && seisuu[2]%i==0)
			{
				cout << i << endl;
			}
		}
	}
	//for (int i=0; i<n; i++) cout << seisuu[i] << endl;

	return 0;
}


#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++)
#define REP(i,n) for(int i = 0;i < (n) ; i++)
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
#define N 1010
int MOD = 1000000007;
int fac[N+1];
int inv[N+1];
ll bitpow(ll x,ll n){
    ll ans = 1;
    while(n > 0){
        if(n%2 == 1) ans = ans * x % MOD;
        x = x * x %MOD;
        n = n >> 1;
    }
    return ans;
}
ll COM(ll n,ll k){
    return fac[n]*inv[k]%MOD*inv[n-k]%MOD;
}
int dp[1010][1010] = {0};
signed main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    fac[0] = 1;
    inv[0] = 1;
    for(int i = 1;i <= N;i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = bitpow(fac[i],MOD-2)%MOD;
    }
    dp[a-1][0] = 1;
    for(int i = a;i <= b;i++){
        for(int j = 0;j <= n;j++){
            dp[i][j] = dp[i-1][j];
            for(int k = c;k <= d;k++){
                if(j-i*k < 0 || i*k > n)break;
                dp[i][j] += dp[i-1][j-i*k] * fac[n-(j-i*k)] %MOD * inv[n-(j-i*k) - i*k] %MOD * inv[k]%MOD * bitpow(inv[i],k)%MOD;
                dp[i][j] %= MOD;
                // if(i == 3){
                //     //cerr << "j : dp[i-1][j-i*k] : fac[n-(j-i*k)] : inv[n-i*k] : inv[k] : bitpow(inv[i],k)" << endl;
                //     //cerr << j << " " << dp[i-1][j-i*k] <<  " : " << fac[n-(j-i*k)]<<  " : "<< inv[n-i*k] <<  " : "<<  inv[k] <<  " : "<<  bitpow(inv[i],k);
                //     //cerr << endl;
                //  }
            }
        }
    }
    cout << dp[b][n] << endl;

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://arc067.contest.atcoder.jp/tasks/arc067_c


#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
ll color[ohara];
V g[ohara];

bool dfs(ll v, ll c) {
  color[v] = c;
  rep(i, Size(g[v])) {
    if (color[g[v][i]] == c) return false;
    if (color[g[v][i]] == 0 && !dfs(g[v][i], -c)) return false;
  }
  return true;
}

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

  cin >> n >> m;
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
  }
  int ok = 1;
  rep(i, n) {
    if (color[i] == 0) {
      if (!dfs(i, 1)) {
        ok = 0;
        break;
      }
    }
    if (!ok) break;
  }
  if (!ok) {
    ans = n * (n - 1) / 2;
  } else {
    ll cou1 = 0, cou2 = 0;
    rep(i, n) {
      if (color[i] == 1)
        cou1++;
      else
        cou2++;
    }
    ans = cou1 * cou2;
  }
  Cout(ans - m);
  return 0;
}

#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=210;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int n,book[N],g[N];
int f[N][N],res;
struct Node { int x,y; }a[N],b[N];
int DFS(int x)
{
    for(ri int i=1;i<=n;i++)
    {
        if(!book[i]&&f[x][i])
        {
            book[i]=1;
            if(g[i]==-1 || DFS(g[i]))
            {
                g[i]=x;
                return 1;
            }
        }
    }
    return 0;
}
signed main()
{
    n=read();
    for(ri int i=1;i<=n;i++) a[i].x=read(), a[i].y=read();
    for(ri int i=1;i<=n;i++) b[i].x=read(), b[i].y=read();
    for(ri int i=1;i<=n;i++)
    for(ri int j=1;j<=n;j++)
    if(a[i].x<b[j].x && a[i].y<b[j].y) f[i][j]=1;
    memset(g,-1,sizeof(g));
    for(ri int i=1;i<=n;i++)
    {
        memset(book,0,sizeof(book));
        if(DFS(i)) res++;
    }
    printf("%lld\n",res);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

ll bridge_dp[9][2] = {};

void create_bridge_dp() {
  bridge_dp[0][0] = 1;
  bridge_dp[1][0] = 1;
  for (int i = 2; i <= 8; i++) {
    // 横線を引かない
    bridge_dp[i][0] = bridge_dp[i - 1][0] + bridge_dp[i - 1][1];
    // 横線を引けるのは左に横線がない場合
    bridge_dp[i][1] = bridge_dp[i - 1][0];
  }
}

ll way_bridge(ll n) {
  if (n <= 0) {
    return 1;
  }
  return bridge_dp[n][0] + bridge_dp[n][1];
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll h, w, k;
  cin >> h >> w >> k;

  create_bridge_dp();

  vvll dp(h + 1, vll(w + 2));
  dp[0][1] = 1;

  rep(y, h) {
    REP(x, w + 1) {
      dp[y + 1][x] = dp[y][x] * way_bridge(x - 1) * way_bridge(w - x);
      dp[y + 1][x] += dp[y][x - 1] * way_bridge(x - 2) * way_bridge(w - x);
      dp[y + 1][x] += dp[y][x + 1] * way_bridge(x - 1) * way_bridge(w - x - 1);
      dp[y + 1][x] %= mod;
    }
  }

  cout << dp[h][k] << endl;

  return 0;
}

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    {
        ull b = n;
        if (d != 0) {
            b = d;
            b += max(0LL, 2 * (n - d - (d + 1 - 1) ));
            b += n - max(d, (n - d + 1 - 1));
        }
        b *= m - 1;
        double ans = (double)b / n / n;
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

const int N = 100005;

bool cmp1(pair<int,pair<int,int>>a, pair<int,pair<int,int>>b){
    return a.S.F<b.S.F;
}

bool cmp2(pair<int,pair<int,int>>a, pair<int,pair<int,int>>b){
    return a.S.S<b.S.S;
}

pair<int,pair<int,int>>c[N];
int par[N],siz[N];

int find(int x){
    while(par[x]!=x){
        x=par[x];
    }
    return x;
}

void un(int a,int b){
    a=find(a);
    b=find(b);
    if(siz[a]<siz[b]){
        par[a]=par[b];
        siz[b]+=siz[a];
    }
    else{
        par[b]=par[a];
        siz[a]+=siz[b];
    }
}

int main(){
    IOS

    int n;
    cin>>n;
    FOR(i,1,n+1){
        par[i]=i;
        siz[i]=1;
        c[i].F=i;
        cin>>c[i].S.F>>c[i].S.S;
    }

    vector<pair<int,pair<int,int>>>v;

    sort(c+1,c+n+1,cmp1);

    FOR(i,1,n){
        v.pb(mp(c[i+1].S.F-c[i].S.F,mp(c[i].F,c[i+1].F)));
    }
    sort(c+1,c+n+1,cmp2);
    FOR(i,1,n){
        v.pb(mp(c[i+1].S.S-c[i].S.S,mp(c[i].F,c[i+1].F)));
    }
    sort(all(v));

    int cnt=0;
    int i=0;
    ll ans=0;
    while(cnt<n-1){
        int x=find(v[i].S.F),y=find(v[i].S.S);
        if(x==y){
            i++;
            continue;
        }
        un(x,y);
        ans+=v[i].F;
        i++;
        cnt++;
    }
    cout<<ans;

    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P; // pair(coordinate, index)

struct Edge {
    ll from, to, cost;
    Edge(){}
    Edge(ll from, ll to, ll cost):from(from),to(to),cost(cost){}
};

bool comp(const Edge &e1, const Edge &e2) {
    return e1.cost<e2.cost;
}

class union_find {
private:
    vector<ll> par;
    vector<ll> ran;
    vector<ll> m_size;
public:
    union_find(int n);
    int find(int x);
    void unite(int x, int y);
    bool same(int x, int y);
    ll size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    ran.resize(n, 0);
    m_size.resize(n, 1);
};

int union_find::find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (ran[x] < ran[y]) swap(x,y);
    par[y] = x;
    m_size[x] += m_size[y];
    if (ran[x]==ran[y]) ran[x]++;
};

ll union_find::size(int x) {
    return m_size[find(x)];
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

vector<Edge> g;

int V;

ll kruskal() {
    sort(g.begin(), g.end(), comp);
    union_find uf(V+1);
    ll res = 0ll;
    for (auto &&e: g) {
        if (!uf.same(e.from,e.to)) {
            uf.unite(e.from,e.to);
            res+=e.cost;
        }
    }
    return res;
}

int main(int argc, char const *argv[]) {
    cin>>V;
    vector<P> X, Y;

    rep(i,V) {
        ll x,y; cin>>x>>y;
        X.emplace_back(x,i); Y.emplace_back(y,i);
    }

    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    rep(i,V-1) {
        ll from = X[i].second; ll to = X[i+1].second;
        ll cost = X[i+1].first-X[i].first;
        g.emplace_back(from,to,cost);
        from = Y[i].second; to = Y[i+1].second;
        cost = Y[i+1].first-Y[i].first;
        g.emplace_back(from,to,cost);
    }

    cout << kruskal() << endl;

    return 0;
}


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

int main() {

  int n;
  cin >> n;

  string s = to_string(n);
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == '7'){
      ans = 1;
    }
  }

  if(ans == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}

#include<iostream>
using namespace std;
int main (void)
{
  int r;
  cin>>r;
  while(r>1)
  {

    if(r%10==7)
    {
      cout<<"Yes";return 0;
    }
    r=r/10;
  }
  cout<<"No";
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;

const int maxn=1e5+5;
int fa[maxn];
int tot;
struct way{
    int u,v;
	long long w;
}edge[maxn*4];
struct node
{
	int x,y,id;
}a[maxn];
int find(int x){return fa[x]==x?fa[x]:fa[x]=find(fa[x]);}
void link(int x,int y)
{
    int tx=find(x),ty=find(y);
    fa[ty]=tx;
}
bool cmp(way a,way b){return a.w<b.w;}
bool cmp1(node a,node b){return a.x<b.x;}
bool cmp2(node a,node b){return a.y<b.y;}
int main()
{
    int m,n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	a[i].id=i;
    	scanf("%d %d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+1+n,cmp1);
	int cnt=0;
    for(int i=1;i<n;i++)
    {
    	cnt++;
    	edge[cnt].u=a[i].id;
    	edge[cnt].v=a[i+1].id;
    	edge[cnt].w=(long long)(a[i+1].x-a[i].x);
    	cnt++;
    	edge[cnt].u=a[i+1].id;
    	edge[cnt].v=a[i].id;
    	edge[cnt].w=(long long)(a[i+1].x-a[i].x);
	}
	sort(a+1,a+1+n,cmp2);
	for(int i=1;i<n;i++)
    {
    	cnt++;
    	edge[cnt].u=a[i].id;
    	edge[cnt].v=a[i+1].id;
    	edge[cnt].w=(long long)(a[i+1].y-a[i].y);
    	cnt++;
    	edge[cnt].u=a[i+1].id;
    	edge[cnt].v=a[i].id;
    	edge[cnt].w=(long long)(a[i+1].y-a[i].y);
	}
    for(int i=1;i<=n;i++)    fa[i]=i;
    sort(edge+1,edge+cnt+1,cmp);
    for(int i=1;i<=cnt;i++)
    {
        if(find(edge[i].u)!=find(edge[i].v))
        {
            link(edge[i].u,edge[i].v);
            tot=tot+edge[i].w;
        }
    }
    cout<<tot<<endl;
    return 0;
}

#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

const int N = 100005;

bool cmp1(pair<int,pair<int,int>>a, pair<int,pair<int,int>>b){
    return a.S.F<b.S.F;
}

bool cmp2(pair<int,pair<int,int>>a, pair<int,pair<int,int>>b){
    return a.S.S<b.S.S;
}

pair<int,pair<int,int>>c[N];
int par[N],siz[N];

int find(int x){
    while(par[x]!=x){
        x=par[x];
    }
    return x;
}

void un(int a,int b){
    a=find(a);
    b=find(b);
    if(siz[a]<siz[b]){
        par[a]=par[b];
        siz[b]+=siz[a];
    }
    else{
        par[b]=par[a];
        siz[a]+=siz[b];
    }
}

int main(){
    IOS

    int n;
    cin>>n;
    FOR(i,1,n+1){
        par[i]=i;
        siz[i]=1;
        c[i].F=i;
        cin>>c[i].S.F>>c[i].S.S;
    }

    vector<pair<int,pair<int,int>>>v;

    sort(c+1,c+n+1,cmp1);

    FOR(i,1,n){
        v.pb(mp(c[i+1].S.F-c[i].S.F,mp(c[i].F,c[i+1].F)));
    }
    sort(c+1,c+n+1,cmp2);
    FOR(i,1,n){
        v.pb(mp(c[i+1].S.S-c[i].S.S,mp(c[i].F,c[i+1].F)));
    }
    sort(all(v));

    int cnt=0;
    int i=0;
    ll ans=0;
    while(cnt<n-1){
        int x=find(v[i].S.F),y=find(v[i].S.S);
        if(x==y){
            i++;
            continue;
        }
        un(x,y);
        ans+=v[i].F;
        i++;
        cnt++;
    }
    cout<<ans;

    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}


#include <iostream>
#include <memory>
#include <cmath>

constexpr int max_size()
{
    return static_cast<int>(1e+6);
}

int insert(int* a, const int i, const int gear)
{
    if (i < gear) {
        return 0;
    }

    if (a[i - gear] <= a[i]) {
        return 0;
    }

    std::swap(a[i - gear], a[i]);
    return 1 + insert(a, i - gear, gear);
}

int insertion_sort(int* arr, const int n, const int gear)
{
    int insert_count = 0;
    for (int i = 0; i < n; i += gear) {
        insert_count += insert(arr, i, gear);
    }
    return insert_count;
}

int pow(const int a, const int x) {
    return x == 0 ? 1 : a * pow(a, x - 1);
}

void print(int* arr, const int n, const int i, char const delim) {
    if (i == n - 1) {
        std::cout << arr[i];
        return;
    }

    std::cout << arr[i] << delim;
    print(arr, n, i + 1, delim);
}

void print(int* arr, const int n, char const delim) {
    int i = 0;
    for (; i < n - 1; ++i) {
        std::cout << arr[i] << delim;
    }
    std::cout << arr[i];
}

void shell_sort(int* arr, const int n) {
    static const double log3 = std::log(3);
    const int gear_index = static_cast<int>(std::log(2 * n + 1) / log3 - 1);
    int gear = (pow(3, gear_index + 1) - 1) >> 1;

    int gear_cache[100];
    int cache_idx = 0;
    int insert_count = 0;

    for (; gear > 0; gear = (gear - 1) / 3) {
        gear_cache[cache_idx] = gear;
        for (int i = 0; i < gear; ++i) {
            insert_count += insertion_sort(arr + i, n - i, gear);
        }
        ++cache_idx;
    }

    std::cout << cache_idx << std::endl;
    print(gear_cache, cache_idx, ' ');
    std::cout << std::endl;
    std::cout << insert_count << std::endl;

    return;
}

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

    int n;
    std::cin >> n;

    constexpr int N = max_size();
    const auto r = std::make_unique<int[]>(N);
    for (int i = 0; i < n; ++i) {
        std::cin >> r[i];
    }

    shell_sort(r.get(), n);
    print(r.get(), n, '\n');
    std::cout << std::endl;

    return 0;
}

#include <iostream>
using namespace std;
int main(void){
  int cnt=0,m=0,n,a[1000000],g[100]={0};
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  g[0]=1;
  while(g[m]<n){
    g[m+1]=3*g[m]+1;
    m++;
  }
  if(n==1)
    m=1;
  for(int i=m-1;i>=0;i--){
    for(int k=g[i];k<n;k++){
      int v=a[k];
      int j=k-g[i];
      while(j>=0&&a[j]>v){
	a[j+g[i]]=a[j];
	j=j-g[i];
	cnt++;
      }
      a[j+g[i]]=v;
    }
  }
  cout<<m<<endl;
  for(int i=m-1;i>0;i--)
    cout<<g[i]<<" ";
  cout<<g[0]<<endl;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++)
    cout<<a[i]<<endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define very_slow       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vec             vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define inf             1e18
#define MAX             1e9
#define MIN            -1e9
#define no_of_test(x)        int x; cin>>x; while(x--)
//Actual Code Is At The Top
const int mod = 1e9 + 7;
int gcd(int a, int b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}
int binary_exponentation(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (ret * a) % mod;
		b >>= 1;
		a = (a * a) % mod;
	}
	return ret;
}
int32_t main()
{
	very_slow
//	no_of_test(x)
	{
      int n;
      cin>>n;
      int r=0,k=0;
      if(n>=500)
      {
         r=n/500;
         n=n-(r*500);
      }
      if(n>=20)
      {
           k=n/5;

      }
      cout<<r*1000+k*5<<'\n';
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='C') ans++;
    }
    if(ans>=1) cout << "Yes";
    else cout << "No";
}


#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    for(int n, m, s; s = 0, cin >> n >> m, n; cout << s << endl){
        priority_queue<int> p;
        rep(i, n){
            int in; cin >> in;
            p.push(in);
        }
        COUNT(i, n){
            if(i % m) s += p.top();
            p.pop();
        }
    }

    return 0;
}

#include <bits/stdc++.h>
#define r(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
  int a,b,i;
  while(cin>>a>>b,a){
    int c[a],s=0,k=0,p=0;
    r(i,a){cin>>c[i];p+=c[i];}
    sort(c,c+a);
    for(i=a-1;i>=0;i--){
      k++;
      if(k==b){
        s+=c[i];
        k=0;
      }
    }
    cout<<p-s<<endl;;
  }
}


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

int main(){
  string sa;
  cin >> sa;
  int chain = 0;
  int ma = 0;
  for (char j : sa){
    if (j == 'R'){
      chain ++;
    }else chain = 0;
    ma = max(ma,chain);
  }
  cout << ma << endl;
}

#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  if(S == "RRS" || S == "SRR") cout << 2 << endl;
  else if(S == "RRR") cout << 3 << endl;
  else if(S == "SSS") cout << 0 << endl;
  else cout << 1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    ll N,K;
    cin>>N>>K;
    ll cnt=1;
    rep(i,N){
        if(cnt<K){
            cnt*=2;
        }
        else{
            cnt+=K;
        }
    }
    cout<<cnt<<endl;
}

#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define d 1000000007
using namespace std;
int main()
{
    int t;
    t=1;
    while(t--)
    {
        int n,k;
        cin >> n;
        cin >> k;
        int result=1;
        while(n>0)
        {
            result=min(result*2,result+k);
            n--;
        }
        cout << result << endl;
    }
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vi level,memo;
vvi v;
ll n;
void bfs(ll s){
    level=vi(n,inf);
    queue<P> q;
    q.push(P(s,0));
    level[s]=0;
    while(!q.empty()){
        auto t=q.front();q.pop();
        rep(i,n)if(v[t.fi][i]){
            if(chmin(level[i],t.se+1))q.push(P(i,t.se+1));
        }
    }
}
ll dfs(ll i,ll t,ll f){
    if(i==t)return f;
    REP(j,memo[i],n){
        memo[i]++;
        if(v[i][j]==0||level[i]>=level[j])continue;
        ll d=dfs(j,t,min(f,v[i][j]));
        if(d>0){
            v[i][j]-=d;
            v[j][i]+=d;
            return d;
        }
    }
    return 0;
}
ll max_flow(ll s,ll t){
    ll flow=0;
    while(true){
        bfs(s);
        if(level[t]==inf)return flow;
        memo=vi(n);
        while(true){
            ll f=dfs(s,t,inf);
            if(f==0)break;
            flow+=f;
        }
    }
    return flow;
}
int main(){
    cin>>n;
    v=vvi(n*2+2,vi(n*2+2));
    vp point(2*n);
    rep(i,2*n)cin>>point[i].fi>>point[i].se;
    rep(i,n)rep(j,n)if(point[i].fi<=point[j+n].fi&&point[i].se<=point[j+n].se){
        v[i+1][j+n+1]++;
    }
    rep(i,n)v[0][i+1]++;
    rep(i,n)v[i+n+1][n*2+1]++;
    n=n*2+2;
    outs(max_flow(0,n-1),-1);
}

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>> a(N),b(N);
  for(int i(0);i<N;i++){
    cin>>a[i].second>>a[i].first;
  }
  for(int i(0);i<N;i++){
    cin>>b[i].first>>b[i].second;
  }
  sort(a.rbegin(),a.rend());
  sort(b.begin(),b.end());
  int ans(0);
  int used[100] = {0};
  for(int i(0);i<N;i++){
    for(int j(0);j<N;j++){
      if(a[j].second < b[i].first){
        if(used[j] == 0 && a[j].first < b[i].second){
          used[j] = 1;
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


#include<stdio.h>
#include<algorithm>
#define reg register
#define ri reg int
#define rep(i, x, y) for(ri i = x; i <= y; ++i)
#define nrep(i, x, y) for(ri i = x; i >= y; --i)
#define DEBUG 1
#define ll long long
#define max(i, j) (i) > (j) ? (i) : (j)
#define min(i, j) (i) < (j) ? (i) : (j)
struct IO {
	#define MAXSIZE (1 << 20)
	#define isdigit(x) (x >= '0' && x <= '9')
	char buf[MAXSIZE], *p1, *p2;
	char pbuf[MAXSIZE], *pp;
	#if DEBUG
	#else
		IO() : p1(buf), p2(buf), pp(pbuf) {}
		~IO() {
			fwrite(pbuf, 1, pp - pbuf, stdout);
		}
	#endif
	inline char gc() {
		#if DEBUG
    		return getchar();
		#endif
    	if(p1 == p2)
			p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
    	return p1 == p2 ? ' ' : *p1++;
	}
	inline bool blank(char ch) {
    	return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
	}
	template <class T>
	inline void read(T &x) {
    	register double tmp = 1;
    	register bool sign = 0;
    	x = 0;
    	register char ch = gc();
    	for(; !isdigit(ch); ch = gc())
    		if(ch == '-') sign = 1;
    	for(; isdigit(ch); ch = gc())
			x = x * 10 + (ch - '0');
    	if(ch == '.')
			for(ch = gc(); isdigit(ch); ch = gc())
        		tmp /= 10.0, x += tmp * (ch - '0');
    	if(sign) x = -x;
	}
	inline void read(char *s) {
		register char ch = gc();
		for(; blank(ch); ch = gc());
		for(; !blank(ch); ch = gc())
			*s++ = ch;
    	*s = 0;
	}
	inline void read(char &c) {
    	for(c = gc(); blank(c); c = gc());
	}
	inline void push(const char &c) {
		#if DEBUG
    		putchar(c);
		#else
    		if(pp - pbuf == MAXSIZE) {
				fwrite(pbuf, 1, MAXSIZE, stdout);
				pp = pbuf;
			}
    		*pp++ = c;
		#endif
	}
	template <class T>
	inline void write(T x) {
    	if(x < 0) {
			x = -x;
			push('-');
		}
    	static T sta[35];
    	T top = 0;
    	do{
			sta[top++] = x % 10;
			x /= 10;
    	}while(x);
    	while(top)
			push(sta[--top] + '0');
	}
	template <class T>
	inline void write(T x, char lastChar) {
    	write(x);
		push(lastChar);
	}
} io;
int a[110], n, ans;
int main() {
	io.read(n);
	rep(i, 1, n * 2) io.read(a[i]);
	std::sort(a + 1, a + 2 * n + 1);
	rep(i, 1, n) ans += a[2 * i - 1];
	io.write(ans);
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,res=0;
    scanf("%d",&n);
    n*=2;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr.begin(),arr.end());
    for(int i=0;i<n;i+=2)
    {
        res+=arr[i];
    }
    printf("%d",res);
}