//code by Piyush Anand
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

// a new data structure defined. Please refer below
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;




new_data_set p;
typedef  long long  int ll;
#define v_at_in(n) *p.find_by_order(ll n)
#define in_of_v(n)  p.order_of_key(ll n)
#define PI 3.14159265
#define pb push_back
#define pr cout<<'\n'
#define vec vector<ll>
#define vecs vector<string>
#define pii pair<ll,ll>
#define VP vector< pii >
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define mm " "
#define MM " "
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define f0 for(ll i=0;i<n;i++)
#define f1 for(ll i=1;i<=n;i++)
#define frev for(ll i=n-1;i>=0;i--)
#define inloop for(ll i=0;i<n;i++)cin>>a[i];
#define fa(x,v) for(auto x:v)
#define INF (ll)(9e18)
#define univec(v) v.resize(unique(all(v))-v.begin())
#define Sort(v) sort(v.begin(),v.end())
#define test ll T;cin>>T;while(T--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(a,max3(b,c,d))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
 const ll MOD=1000000000+7;
const ll MOD1 = 998244353;

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

}

ll fact(ll n)
{
    if (n == 0)
        return 1;
    return n * fact(n - 1);
}




ll maxXYZWrtAxByCzn(ll n, ll a, ll b, ll c)
{
    ll maxVal = 0;
    for (ll i = 0; i <= n; i += a)

        for (ll j = 0; j <= n - i; j += b) {
            float z = (n - (i + j)) / c;
            if (floor(z) == ceil(z)) {
                ll x = i / a;
                ll y = j / b;
        maxVal = max(maxVal,(ll)( x + y + z));
      //  ans=max3(x,y,z);
            }
        }

    return maxVal;
}
vec v;

void Divisors(ll n)
{
    for (ll i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {

            if (n/i == i)
               v.pb(i);
            else // Otherwise print both
                {
                    v.pb(i);
                    v.pb(n/i);
                }
        }
        if(v.size()==4)
            break;
    }
}


 bool prime[1000000+1];
void sieve(ll n)
{
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}



int main()
{
    fast;

  // ind_by_order(5);
    //p.order_of_key(12);
    ll a,b,c,d,e,ans=0;
    vec v;
    cin>>a>>b>>c>>d>>e;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    v.pb(d);
    v.pb(e);
    f(i,0,5)
    {
        if(v[i]==0)
        {
            ans=i+1;
            break;
        }
    }
   /* p.insert(a);
     p.insert(b);
      p.insert(c);
       p.insert(d);
        p.insert(e);
        ll ans=(p.order_of_key(0))+1;*/

    cout<<ans<<endl;




    return 0;

}
/*    string s1,s2;
    cin>>s1;
    cin>>s2;
    ll p=0,q=0;
    f(i,0,s1.size())
    {
        if(s1[i]=='+')
            p++;
        else
            q++;
    }
    ll pos=p-q,p1=0,q1=0,q2=0;
    f(i,0,s2.size())
    {
        if(s2[i]=='+')
            p1++;
        else if(s2[i]=='-')
            q1++;
        else
            q2++;
    }

    ll pos1=p1-q1;
    ll diff=pos-pos1;
    double ans=0;
    if(diff==0)
    {if(q2%2!=0)
        ans=0;
    else
        ans=0;
ans=((1.0*fact(q2)/(fact(q2/2)*fact(q2/2)))/pow(2,q2)));}
       }
        else{

    if(diff>=q2*(-1)&&diff<=q2)
    {
        if((q2-diff)%2!=0)
            ans=0;
       else
       {

       }
    }
    else
        ans=0;
        }




     ll n;
    cin>>n;
    ll b[n+1];
    vec v;
    vec v1;
    vec v2;
    deque <ll> s;
    memset(b,0,sizeof(b));
    ll a[n+1];
    f(i,1,n+1){
    cin>>a[i];
    b[a[i]]=1;}
    f(i,1,n+1)
    {

      //  if(a[i]==0)
        //    v1.pb(i);
        if(b[i]==0&&a[i]==0)
            s.push_back(i);
       else  if(b[i]==0&&a[i]!=0)
            v.pb(i);
    }
  //  cout<<b[6]<<a[6];
  //  sort(all(v));
    sort(all(v2));
 /*   ll tmp1=0;
    ll nn=v2.size()-(v2.size()%2);
     f(i,1,n+1)
    {
      if(a[i]==0&&tmp1<nn){

            a[i]=v2[nn-tmp1-1];
            tmp1++;
            b[i]=1;}
      }

  /*  vec v3;
    f(i,1,n+1)
    {
        if(b[i]==0)
            v3.pb(i);
    }
    ll tmp=0;
    if(v2.size()%2!=0)
        v.pb(v2[v2.size()-1]);
  /*  f(i,1,n+1)
    {
      if(a[i]==0){
            a[i]=v[v.size()-1];
            b[i]=1;
            break;}
    }
    if(!v.empty()){
    ll tmp=0;
    f(i,1,n+1)
    {
      if(a[i]==0){



    if(!s.empty()&&s.front()!=i&&s.size()%2!=0){
           a[i]=s.front();
      s.pop_front();}


    else if(!s.empty()&&s.back()!=i&&s.size()%2==0){
           a[i]=s.back();
      s.pop_back();}
       else{
         a[i]=v[tmp];
     tmp++;}

      }

    }


    }

    else
    {
        if(s.size()%2!=0)
        {
            ll x=s.front();
            s.pop_front();
            f(i,1,n+1)
    {
      if(a[i]==0){
           if(!s.empty()){
           a[i]=s.front();
      s.pop_front();}
        }
    }

         f(i,1,n+1)
    {
      if(a[i]==0){
            a[i]=x;}

    }
        }
        else{
        f(i,1,n+1)
    {
      if(a[i]==0){
           if(!s.empty()){
           a[i]=s.back();
      s.pop_back();}


      }

    }
        }
    }

//cout<<v[0]<<v[1];

    f(i,1,n+1)
    cout<<a[i]<<" ";
        */


Measured memory_bytes: 3632