#include<bits/stdc++.h> 
using namespace std; 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define forp(i,a,b) for (int i = a; i <b; i++)
#define forn(i,a,b) for (int i = a; i >b; i--)
#define mod 1000000007
#define MAX 50
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;


long long int fact(long long int n)
{
  if(n==0 || n==1)
  return 1;
  else
  return (n*fact(n-1)%mod)%mod;
}

int prime(long long int n)
{
  for(int i=2;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      return 0;
    }
  }
  return 1;
}

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

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

int check_palin(string s)
{
  string str=s;
  reverse(str.begin(),str.end());
  if(str==s)
  return 1;
  else 
  return 0;
}

 
bool isSafe(int row, int col, int m[50][50],int n,int c, bool visited[50][50]) 
{ 
   if (row == -1 || row == n || col == -1 ||  col == c || visited[row][col] || m[row][col] == 0) 
        return false; 
  
    return true; 
} 
  
 
void printPathUtil(int row, int col, int m[50][50], int n,int c, string& path,vector<string>&possiblePaths, bool visited[][MAX]) 
{ 
    if (row == -1 || row == n || col == -1  
               || col == c || visited[row][col]  
                           || m[row][col] == 0) 
        return; 
  
    if (row == n - 1 && col == c - 1) { 
        possiblePaths.push_back(path); 
        return; 
    } 
    visited[row][col] = true; 

    if (isSafe(row + 1, col, m, n,c, visited)) 
    { 
        path.push_back('D'); 
        printPathUtil(row + 1, col, m, n,c, 
                 path, possiblePaths, visited); 
        path.pop_back(); 
    } 

    if (isSafe(row, col - 1, m, n,c, visited)) 
    { 
        path.push_back('L'); 
        printPathUtil(row, col - 1, m, n,c, 
                   path, possiblePaths, visited); 
        path.pop_back(); 
    } 

    if (isSafe(row, col + 1, m, n,c, visited))  
    { 
        path.push_back('R'); 
        printPathUtil(row, col + 1, m, n,c, 
                   path, possiblePaths, visited); 
        path.pop_back(); 
    } 

    if (isSafe(row - 1, col, m, n,c, visited)) 
    { 
        path.push_back('U'); 
        printPathUtil(row - 1, col, m, n,c, 
               path, possiblePaths, visited); 
        path.pop_back(); 
    } 

    visited[row][col] = false; 
} 
  

int printPath(int m[50][50], int n,int c,vector<pair<int,int>> good) 
{ 

    vector<string> possiblePaths; 
    int ans=0;
    string path; 
    bool visited[50][50]; 
    forp(i,0,50)
    forp(j,0,50)
    visited[i][j]=false;
    forp(i,0,good.size())
    {
    printPathUtil(good[i].F,good[i].S, m, n,c, path,  
                      possiblePaths, visited); 
    if(possiblePaths.size()==0)
    {
      ans=0;
      break;
    }
    else
    ans++;
    }
    
    return ans;
    
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
            long long int n,m,z=1,index;
            for(int i=0;i<5;i++)
            {
              cin>>n;
              if(n==0)
              z=i+1;
            }

            
 cout<<z;          // cout<<"\n";
        
            
            
            
return 0;
}
            
            
            
            

Measured memory_bytes: 3616