#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int h, m;
  h = (s[0] - 48) * 10 + s[1] - 48;
  m = (s[3] - 48) * 10 + s[4] - 48;
  int a[25];
  a[0] = 0;
  a[1] = 10;
  a[2] = 20;
  a[3] = 30;
  a[4] = 40;
  a[5] = 50;
  a[6] = -1;
  a[7] = -1;
  a[8] = -1;
  a[9] = -1;
  a[10] = 1;
  a[11] = 11;
  a[12] = 21;
  a[13] = 31;
  a[14] = 41;
  a[15] = 51;
  a[16] = -1;
  a[17] = -1;
  a[18] = -1;
  a[19] = -1;
  a[20] = 2;
  a[21] = 12;
  a[22] = 22;
  a[23] = 32;
  a[24] = 0;
  int nh;
  if (m > a[h]) {
    nh = h + 1;
    while (a[nh] == -1) nh++;
  } else {
    nh = h;
  }
  cout << (nh - h) * 60 + a[nh] - m;
  return 0;
}
